Google Calendar Zend_Loader errors

落爺英雄遲暮 提交于 2019-12-13 07:15:09

问题


I'm running into some errors with Zend_Loader (1.10.8) when I initialize the Google Calendar API in PHP. Here is my code:

\Zend_Loader::loadClass('Zend_Gdata');
\Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
\Zend_Loader::loadClass('Zend_Gdata_Calendar');
$this->_service = \Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$this->_client  = \Zend_Gdata_ClientLogin::getHttpClient(USER, PASS, $this->_service);
$this->_client->setConfig(array('keepalive' => true));
$this->_service = new \Zend_Gdata_Calendar($this->_client);
$this->defaultQuery = $this->_service->newEventQuery();

That last line gives the following errors:

Warning: include_once(Zend/Gdata/Calendar/Extension/EventQuery.php): failed to open stream: No such file or directory
Warning: include_once(): Failed opening 'Zend/Gdata/Calendar/Extension/EventQuery.php' for inclusion

This doesn't break any functionality, but I can't figure out how to resolve the errors. My EventQuery.php files lives in "/Zend/Gdata/Calendar/EventQuery.php" and not the path it's using in the error. Any ideas?


回答1:


It's a bug, and it seems it occurs again in newer versions of ZendFramework

here is the original http://framework.zend.com/issues/browse/ZF-7013?focusedCommentId=49379

here is the one i reopened but nothing happends http://framework.zend.com/issues/browse/ZF-11959




回答2:


This happens when you've registered an error handler which throws an Exception:

set_error_handler('errorFunction');

function errorFunction($errno, $errstr, $errfile, $errline)
{
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

In Zend/Gdata/App.php version 1.11.11, lines 1046 to 1059:

1046             foreach ($this->_registeredPackages as $name) {
1047                  try {
1048                      // Autoloading disabled on next line for compatibility
1049                      // with magic factories. See ZF-6660.
1050                      if (!class_exists($name . '_' . $class, false)) {
1051                         require_once 'Zend/Loader.php';
1052                         @Zend_Loader::loadClass($name . '_' . $class);
1053                      }  
1054                      $foundClassName = $name . '_' . $class;
1055                      break;
1056                  } catch (Zend_Exception $e) {
1057                      // package wasn't here- continue searching
1058                  }   
1059             }

The class relies on the loader to throw a Zend_Exception if the file / class it tries to load doesn't exist, or just suppresses the error with the @ symbol.

Throwing the ErrorException in the error handler bypasses the error suppression, and causes this code to fail.

The Solution

I've commented on the ZF issue the reason and a potential fix for the problem. In the mean time, you can just add the following on lines 1058 - 1060

} catch (ErrorException $e) {
    //Do Nothing, just the file not found error
}

or just change the Zend_Exception on line 1056 to the base Exception, as it's done in ZF2.



来源:https://stackoverflow.com/questions/8438715/google-calendar-zend-loader-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!