【问题标题】:Zend Framework - No data receivedZend 框架 - 未收到数据
【发布时间】:2014-10-22 00:02:21
【问题描述】:

我正在开发 Zend Framework 1.11 版,但遇到了以下问题:
提交表单后,浏览器显示“未收到数据:无法加载网页,因为服务器未发送数据。” (在 chrome 上)和“在页面加载时重置了与服务器的连接。”在火狐上。
现在,可能与我的机器有关,因为我无法在具有类似配置的其他机器上重现错误,除了服务器版本(我已升级到 apache 2.4.7,其他机器有 apache 2.2)。
现在请求通过的代码是:

$form = new Website_Form_ArtUpload();
        if ($this->getRequest()->isPost())
        {
            $response = $this->_getService()->upload($this->getRequest()->getPost());
            My_Logger::log(print_r($response));
            if (!$response->isValid()) {
                if($response->getData() instanceof Zend_Form) {
                    $form = $response->getData();
                }
                if($response->hasMessages()) {
                    My_Logger::log(print_r($response->getAllMessages()));
                    $this->view->messages = $response->getAllMessages();
                }
            }  else {
                $this->_helper->redirector->gotoSimple('new', 'product', 'website');
                return;
            }
        }

$this->_getService()->upload()的内容

// Validate the form
    $form = new Website_Form_ArtUpload();
    if (!$form->isValid($data))
        return new My_Service_Response(
            My_Service_Response::FAILURE,
            $form,
            array(My_Model_Message::MESSAGE_TYPE_ERROR => $this->getTranslator()->_('The product cannot be uploaded'))
        ); //here it halts

所以,这一次,我不知道为什么数据不应该是有效的,因为一切似乎都很好。但是假设数据确实无效,因为响应失败并且有消息($this->view->messages = $response->getAllMessages() 记录消息),我不明白为什么不只是一个很好的错误说“产品无法上传” .

如果您需要任何其他代码或日志,我很乐意提供。

注意:其他有错误的表单会正确返回消息。 请不要告诉我我们应该有相同的服务器版本,我知道,但是如果将来某个时候我们想要迁移到 2.4,我们宁愿已经解决这个问题。

【问题讨论】:

    标签: php apache zend-framework apache2.4


    【解决方案1】:

    这是由于图像验证 MIME 类型、文件大小……等原因造成的。

    if (!$form->isValid($data)) {
    ...
    }
    

    此问题已在最新的 Zend Framework 1.12.9 中修复,您只需从 https://packages.zendframework.com/releases/ZendFramework-1.12.9/ZendFramework-1.12.9.zip

    如果您不需要更新完整的框架,只需替换所有文件 “ library -> Zend -> Validate -> File” 包含来自 ZendFramework-1.12.9 的最新文件

    确保在更新后测试所有页面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-13
      • 2012-08-18
      相关资源
      最近更新 更多