1

这是这个问题的后续问题,这并不重要。

我编写了以下前端控制器插件:

public function postDispatch(Zend_Controller_Request_Abstract $request)
{
    $response = $this->getResponse();
    $monitor = Zend_Registry::get('monitor');
    
    if ($response->isException())
    {
        $monitor->log($response);
    }
}

其中 $monitor 是自定义 DB 日志记录类的一个实例(扩展 Zend_Log)。

在 Monitor 的 log 方法中,我遍历 $response->getException() 返回的 Zend_Exceptions 数组。

出于测试目的,我通过操作中的异常:

throw new Zend_Exception('the big test', 555);

大多数事情都按预期工作,异常被写入数据库。

问题

但是,它写了两次。为什么?

4

1 回答 1

3

因为调度循环被调用了两次。首先是当前操作,然后是 default:error:error :) 将日志放入dispatchLoopShutdown()方法

于 2011-03-20T16:50:08.900 回答