Issues

ZF-9497: Zend_Application_Resource_Log does not pass db instance to "db" writer via ini file

Description

resources.log.db.writerName = "Db" resources.log.db.writerParams.adapter = <> resources.log.db.writerParams.table = "log"

Examination of the Zend_Log_Writer_DB reveals that "factory($config = array())" requires the following: array( 'db' => null, 'table' => null, 'columnMap' => null, ) The db connector cannot be passed with the application.ini file.

The following code added to Zend_Application_Resource_Log solves this problem two ways: if there is config data, a database connection is properly assigned; or, if there is default database connection, use the Zend_Db_Table default connection set under db resource.

public function getLog() { if (null === $this->_log) { $options = $this->getOptions (); if (is_array ( $options )) { //add the db adapter where needed foreach ( $options as $key => $option ) { //first see if db writer if (isset ( $option ['writerName'] ) && strtolower ( $option ['writerName'] ) == "db") { if (isset ( $option ['writerName'], $option ['writerParams'] ['adapter'], $option ['writerParams'] ['params'] )) { $options [$key] ['writerParams'] ['db'] = Zend_Db::factory ( $option ['writerParams'] ['adapter'], $option ['writerParams'] ['params'] ); unset ( $options [$key] ['writerParams'] ['adapter'], $options [$key] ['writerParams'] ['params'] ); } else { //see if we have a default adapter, use that $defaultAdapter = Zend_Db_Table::getDefaultAdapter (); if (! is_null ( $default )) $options [$key] ['writerParams'] ['db'] = $defaultAdapter; } } } } $log = Zend_Log::factory ( $options ); $this->setLog ( $log ); } return $this->_log; }

Comments

sure, Zend_Log_Writer_Db would be able to get default adpater, but i think it could be better if we add a bit change at Zend/Log/Writer/Db.php, near line 124, because there log writer knows that there is no adapter

What are the next steps?

Wait a couple of days for the assignee to evaluate the issue (and find time).

Will get to this soon. Just back from a project so won't be too long ;).

So what's the status for this?