ZF-10617: Instanciating Zend_Log_Writer_Firebug using the factory crashes

Description

If you try using the factory to create a new firebug logger like this


Zend_log::factory(array(
    array(
        "writerName"    => "Firebug",
        "filterName"    => "Priority",
        "filterParams"  => array(
            "priority"  => Zend_Log::INFO,
        ),
    ),
));

you've got the following fatal error: Fatal error: Cannot redeclare class Zend_Log in PATH/Zend/Log.php on line 30

Using normal instanciation does work though:


$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$logger->log('Test message', Zend_Log::INFO);

Correction is to delete the following lines in Zend/log/Writer/firebug.php (lines 23 and 24) /** Zend_Log */ require_once 'Zend/Log.php';

Comments

In your sample code first the a typo is Zend_Log and not Zend_log. Zend_Log_Writer_Syslog and Zend_Log_Writer_Firebug uses constants of the class Zend_Log by this the require_once.

See a case of error if remove require_once of the class Zend_Log_Writer_Firebug.


require_once 'Zend/Log/Writer/Firebug.php';
$writer = new Zend_Log_Writer_Firebug();
$writer->getPriorityStyle(0);

Here a simple code reproduced and not found problem.


$paths = array(
   /* define path */
);

set_include_path(implode(PATH_SEPARATOR, $paths));
require_once 'Zend/Log.php';
Zend_log::factory(array(
    array(
        "writerName" => "Firebug",
        "filterName" => "Priority",
        "filterParams" => array(
            "priority" => Zend_Log::INFO,
        ),
    ),
));

Please provides more information to reproduced.

Greetings Ramon

Actually you are right the problem comes from the misspelling of Zend_Log. I think that the class loader doesn't register the class properly the first time (using Zend_log) and at the second invocation of the class (using Zend_Log this time) the system crashes because it tries to register the class a second time (but the class loader registered Zend_log not Zend_Log)

Sorry for bothering for nothing and thanks for your reactivity.

Removing fix version. Issues marked 'not an issue' don't need a fix version.