【问题标题】:Google Calendar Zend_Loader errorsGoogle 日历 Zend_Loader 错误
【发布时间】:2013-12-29 10:19:52
【问题描述】:

当我在 PHP 中初始化 Google Calendar API 时,我遇到了 Zend_Loader (1.10.8) 的一些错误。这是我的代码:

\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();

最后一行给出以下错误:

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

这不会破坏任何功能,但我不知道如何解决这些错误。我的 EventQuery.php 文件位于“/Zend/Gdata/Calendar/EventQuery.php”中,而不是它在错误中使用的路径。有什么想法吗?

【问题讨论】:

    标签: php zend-framework google-calendar-api


    【解决方案1】:

    这是一个错误,它似乎在较新版本的 ZendFramework 中再次出现

    这里是原http://framework.zend.com/issues/browse/ZF-7013?focusedCommentId=49379

    这是我重新打开的那个,但什么也没发生http://framework.zend.com/issues/browse/ZF-11959

    【讨论】:

      【解决方案2】:

      当您注册了一个抛出异常的错误处理程序时会发生这种情况:

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

      在 Zend/Gdata/App.php 版本 1.11.11 中,第 1046 到 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             }
      

      如果该类尝试加载的文件/类不存在,或者只是使用@ 符号抑制错误,则该类依赖加载器抛出 Zend_Exception。

      在错误处理程序中抛出ErrorException 会绕过错误抑制,并导致此代码失败。

      解决方案

      我已经评论了 ZF 问题的原因和问题的潜在解决方案。同时,您可以在第 1058 - 1060 行添加以下内容

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

      只需将第 1056 行的 Zend_Exception 更改为基础 Exception,就像在 ZF2 中所做的那样。

      【讨论】:

      • 很好,但我的问题是我有一个错误处理程序来记录所有错误,以便我以后可以修复它们,并且每次升级 zendframework 时都必须记住手动应用补丁不太舒服
      • 当然。希望 Zend 的人能尽快解决这个问题。我检查了 ZF2 代码,它已经固定在那里了。
      • 此错误仍显示在1.12.1 中,其中包含上述修复。
      • @Withremote 抛出了什么异常?什么是异常消息?
      • @Jrgns error - 2013-02-19 13:19:25 --> Severity: Warning --> include_once() [<a href='function.include'>function.include</a>]: Failed opening 'Zend/Gdata/Calendar/Extension/EventQuery.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:www:/home/grchamb/public_html/mm/application/libraries') /home/grchamb/public_html/mm/application/libraries/Zend/Loader.php 134 但尽管包含错误,所有功能仍然有效。 Zend_Gdata_App_Exception 没有返回错误。
      猜你喜欢
      • 2018-01-20
      • 1970-01-01
      • 1970-01-01
      • 2014-02-11
      • 2014-03-27
      • 2023-03-07
      • 1970-01-01
      • 2020-05-09
      • 1970-01-01
      相关资源
      最近更新 更多