Zend Framework

Zend_Db_Profiler_Firebug with multiple databases

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: N/A N/A
  • Resolution: Fixed
  • Affects Version/s: 1.6.0RC2
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Db_Profiler
  • Labels:
    None
  • Fix Version Priority:
    Must Have

Description

My page is connected with multiples databases. I activate Zend_Db_Profiler_Firebug as profiler for each one. I enable it for each one. But I only receive the table in Firebug for the first registered database.

Activity

Hide
Matthew Weier O'Phinney added a comment -

Scheduling for RC3

Show
Matthew Weier O'Phinney added a comment - Scheduling for RC3
Hide
Mickael Perraud added a comment -

This is not OK .
You try to register multiple times the Plugin (apparently for each db). This code functions:

/**
 * Register this object as a controller plugin.
 * 
 * @return void
 */
protected function _registerControllerPlugin()
{
    static $already_made = false;
    $controller = Zend_Controller_Front::getInstance();
    try {
        if (!$already_made) {
            $controller->registerPlugin($this, self::$_controllerPluginStackIndex);
            $already_made=true;
        }
    } catch (Zend_Controller_Exception $e) {
        // Exception indicates plugin is already registered
        // which we simply ignore
    }
}
Show
Mickael Perraud added a comment - This is not OK . You try to register multiple times the Plugin (apparently for each db). This code functions:
/**
 * Register this object as a controller plugin.
 * 
 * @return void
 */
protected function _registerControllerPlugin()
{
    static $already_made = false;
    $controller = Zend_Controller_Front::getInstance();
    try {
        if (!$already_made) {
            $controller->registerPlugin($this, self::$_controllerPluginStackIndex);
            $already_made=true;
        }
    } catch (Zend_Controller_Exception $e) {
        // Exception indicates plugin is already registered
        // which we simply ignore
    }
}
Hide
Christoph Dorn added a comment -

Is it displaying a log entry for each DB? It does work for me. Also see the Zend_Wildfire demo.

While the code calls $controller->registerPlugin repeatedly it is in fact only registered once as the registerPlugin() method throws an exception if the plugin is already registered.

I guess the way I am doing it at the moment is no the "clean" way. Rather than keeping a flag in my code I would prefer to call a method on Zend_Controller_Front called isPluginRegistered().

Let's open a new issue for this if the multiple DB logging is working as intended.

Show
Christoph Dorn added a comment - Is it displaying a log entry for each DB? It does work for me. Also see the Zend_Wildfire demo. While the code calls $controller->registerPlugin repeatedly it is in fact only registered once as the registerPlugin() method throws an exception if the plugin is already registered. I guess the way I am doing it at the moment is no the "clean" way. Rather than keeping a flag in my code I would prefer to call a method on Zend_Controller_Front called isPluginRegistered(). Let's open a new issue for this if the multiple DB logging is working as intended.
Hide
Mickael Perraud added a comment -

My problem is with Zend_Db_Profiler_Firebug not with Zend_Log_Writer_Firebug, is that your question?

Without my code, I have nothing in Firebug. With my code, I have the 2 tables in Firebug. Is my response correct?

Show
Mickael Perraud added a comment - My problem is with Zend_Db_Profiler_Firebug not with Zend_Log_Writer_Firebug, is that your question? Without my code, I have nothing in Firebug. With my code, I have the 2 tables in Firebug. Is my response correct?
Hide
Mickael Perraud added a comment -

I understand: I have xDebug which catch the exception before your try/catch.

Show
Mickael Perraud added a comment - I understand: I have xDebug which catch the exception before your try/catch.
Hide
Christoph Dorn added a comment -

I should not rely on the exception for control flow. I'll work on a fix. It will probably not make it into 1.6.0, but will be in 1.6.1

Show
Christoph Dorn added a comment - I should not rely on the exception for control flow. I'll work on a fix. It will probably not make it into 1.6.0, but will be in 1.6.1
Hide
Christoph Dorn added a comment -

The issue is resolved other than when xDebug is installed.

Show
Christoph Dorn added a comment - The issue is resolved other than when xDebug is installed.
Hide
Christoph Dorn added a comment -

Fixed with:

protected function _registerControllerPlugin()
    {
        $controller = Zend_Controller_Front::getInstance();
        if (!$controller->hasPlugin(get_class($this))) {
            $controller->registerPlugin($this, self::$_controllerPluginStackIndex);
        }        
    }
Show
Christoph Dorn added a comment - Fixed with:
protected function _registerControllerPlugin()
    {
        $controller = Zend_Controller_Front::getInstance();
        if (!$controller->hasPlugin(get_class($this))) {
            $controller->registerPlugin($this, self::$_controllerPluginStackIndex);
        }        
    }
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: