【问题标题】:Zend Framework and FireFox inconsistent crashesZend Framework 和 FireFox 不一致的崩溃
【发布时间】:2011-06-19 05:15:31
【问题描述】:

我们的网站在加载/重新加载页面时在 FireFox 中间歇性崩溃。该站点使用 Zend Framework 1.11.7 构建。问题出在我们的生产服务器(共享主机)上,它似乎只在使用 FireFox 时发生,所有其他浏览器我们都无法复制该问题。开发服务器工作正常。该网站已经过验证,但我们使用的 Adob​​e Strobe Media Player 会出现常见的验证错误。

当它崩溃时我们通常会看到

请联系服务器管理员,[未提供地址],并告知他们 > 错误发生的时间,以及您可能所做的任何可能导致错误的事情。

服务器错误日志中可能会提供有关此错误的更多信息。

0 HTTP/1.1 200 OK 日期:2011 年 6 月 19 日星期日 04:33:13 GMT 服务器:Apache/2.2.17 (Unix) > > >FrontPage/5.0.2.2635 X-Powered-By:PHP/5.2。 17 Keep-Alive: timeout=5, max=99 Connection: Keep->Alive Transfer-Encoding: chunked Content-Type: text/html 38fd

上面的消息可以在正文中,也可以是正文中的唯一内容以及 html 源代码。我们还看到上面的消息替换了 Javascript/jQuery 代码。

有时网站会在没有 CSS 的情况下加载,有时则没有 Javascript (jQuery)。

我们的服务器日志中没有错误。

从症状看来,bootstrap.php 文件没有正确加载。

我们使用的是默认的.htaccess,而我们的bootstrap.php是

<?php

类 Bootstrap 扩展 Zend_Application_Bootstrap_Bootstrap {

protected function _initView() {
    $view = new Zend_View();
    $view->doctype('XHTML1_TRANSITIONAL');

    $view->headTitle(' News')
        ->setSeparator(' - ');

    $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');

    $view->headLink(array('rel' => 'shortcut icon',
      'href' => '/css/images/favicon.ico'), 'PREPEND');

    $view->headScript()->appendFile('/js/jquery-1.6.1.min.js')
        ->appendFile('/js/jquery-ui-1.8.13.custom.min.js')
        ->appendFile('/js/validate.js')
        ->appendFile('/js/bloom.js');

    $view->headLink()->appendStylesheet('/css/main.css')
        ->appendStylesheet('/css/trontastic/jquery-ui-1.8.13.custom.css');

    // Add it to the ViewRenderer 
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);

    // Return it, so that it can be stored by the bootstrap 
    return $view;
}

protected function _initAutoload() {
    // Add autoloader empty namespace 
    $autoLoader = Zend_Loader_Autoloader::getInstance();
    $autoLoader->registerNamespace('BloomData_');
    $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
          'basePath' => APPLICATION_PATH,
          'namespace' => '',
          'resourceTypes' => array(
            'form' => array(
              'path' => 'forms/',
              'namespace' => 'Form_',
            ),
            'model' => array(
              'path' => 'models/',
              'namespace' => 'Model_'
            ),
          ),
        ));

    // Return it so that it can be stored by the bootstrap 
    return $autoLoader;
}

protected function _initRoute() {
    $ctrl = Zend_Controller_Front::getInstance();
    $router = $ctrl->getRouter(); // returns a rewrite router by default

    $ir = new Zend_Controller_Router_Route_Regex('id/(.*)',
            array('controller' => 'index', 'action' => 'index'),
            array(1 => 'id'));

    $router->addRoute('idRoute', $ir);

    $sr = new Zend_Controller_Router_Route_Regex('sector/(.*)/id/(.*)',
            array('controller' => 'index', 'action' => 'index'),
            array(1 => 'sector', 2 => 'id'));

    $router->addRoute('sectorRoute', $sr);

    $dr = new Zend_Controller_Router_Route_Regex('date/(.*)/id/(.*)',
            array('controller' => 'index', 'action' => 'index'),
            array(1 => 'date', 2 => 'id'));

    $router->addRoute('dateRoute', $dr);
}

}

【问题讨论】:

  • 你用的是哪个FF版本?

标签: zend-framework


【解决方案1】:

我认为这不是 Firefox 或任何其他浏览器的问题。似乎您没有设置正确的标题,这就是您获得分块内容的原因。尝试在 .htaccess 中添加这些行:

SetEnv force-response-1.0 1
SetEnv downgrade-1.0 1

【讨论】:

  • .htaccess 的更改没有帮助,但是错误的发生频率较低,并且错误将出现在页面底部,此
    200 OK

    OK

    服务器遇到内部错误或配置错误,无法完成您的请求。

    请联系服务器管理员,[未提供地址] 并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。

    有关此错误的更多信息可在服务器错误日志中找到。

  • 使用修改后的 .htaccess 网站也会产生 Chrome 中之前评论中显示的错误(我没有检查过 Safari 或 IE)
【解决方案2】:

Zend 建议使用最新的 PHP 版本。尝试联系您的分片托管服务提供商并要求他们升级到最新的 PHP 5.3 版本。我有类似的奇怪崩溃,只有通过更新 php 版本才能解决。

还要确认您在开发和生产中运行相同的 zend 框架版本。

【讨论】:

  • 如果他们能升级到 5.3 就好了。此时生产是php 5.2.13,开发是5.2.11
猜你喜欢
相关资源
最近更新 更多
热门标签