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

Issue Type: Bug Created: 2010-03-21T10:11:52.000+0000 Last Updated: 2011-06-28T14:09:58.000+0000 Status: Open Fix version(s): Reporter: David Moring (davmor) Assignee: Pádraic Brady (padraic) Tags: - Zend_Application_Resource

Related issues: Attachments:


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; }


Posted by Renan de Lima (renanbr) on 2010-03-22T08:18:24.000+0000

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

Posted by David Moring (davmor) on 2010-03-22T13:19:40.000+0000

What are the next steps?

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-03-22T15:06:44.000+0000

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

Posted by Pádraic Brady (padraic) on 2010-03-24T08:56:51.000+0000

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

Posted by A.J. Brown (ajbrown) on 2011-06-28T14:09:58.000+0000

So what's the status for this?

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.