Home » Logging » Log » Bug #5771
Log_sql objects passed a DB handle fail when log() is called
Details
| Submitted | 2005-10-24 18:39 UTC |
|---|---|
| From | mjohnson at pitsco dot com |
| Assigned | jon |
| Status | Duplicate |
| Package | Log |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-10-24 18:39 UTC] mjohnson at pitsco dot com
Description:
------------
The new version (1.9.0) runs DB::prepare() in open(). open() is not called if the constructor is passed a DB handle.
The fix is simple:
* In the constructor, don't set _opened for a passed DB
handle
* In in open(), wrap the $this->_db assignment and
success check in an if statement that has the
expression '!$this->_db'
If you'd like an actual diff, please let me know.
Test script:
---------------
<?php ;
require_once('DB.php');
require_once('Log.php');
$db =& DB::connect('mysql://user:pwd@localhost/log');
$logger =& Log::singleton('sql', 'log.log_table', 'xyz',
array('db' => &$db,
'sequence' => 'log.log_id'));
echo ($logger->log('This is a test', PEAR_LOG_ERR)) ? 'Success' : 'Failure';
?>
Expected result:
----------------
Success, with an entry in log.log_table.
Actual result:
--------------
Failure, with no entry in log.log_table