1

This is a follow up question of this question, which is not really important.

I have written the following front controller plugin:

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

Where $monitor is an instance of a custom DB logging class (extending Zend_Log).

In the log method of the Monitor I loop over the Array of Zend_Exceptions returned by $response->getException().

For testing purposes I through an exception in an action:

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

Most things work as expected, the Exception is written to the database.

Question

But, it's written twice. Why?

Community
  • 1
  • 1
markus
  • 40,136
  • 23
  • 97
  • 142

1 Answers1

3

Because the dispatch loop is called twice. First for the current action and then for default:error:error :) Place the log into dispatchLoopShutdown() method

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82