PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Logging » Log » Bug #5702

sql bug when using an existing connection

Details

Submitted2005-10-17 01:05 UTC
Fromnorbert_m at php dot net
Assignedjon
StatusClosed
PackageLog
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-10-17 01:05 UTC] norbert_m at php dot net

Description:
------------
If an existing database connection was provided, $_opened is set to true in the constructor of Log_sql. This causes a bug: the statement will never be prepared because it is prepared in function open() only when !$this->_opened.

The workaround is to duplicate the statement preparation. What I suggest is to copy the statement preparation block (5 lines incl. comments) from function open() to the constructor, inside the condition "if (isset($conf['db']))" right after "$this->_existingConnection = true;". I don't think that one more function should be introduced to achieve this.

Test script:
---------------
Any script that passes in a DB object, as described in the Documentation of the Log package.

Expected result:
----------------
Everything works fine.

Actual result:
--------------
Nothing gets logged because the statement is never prepared, so $_statement is always null.

[2005-10-17 01:16 UTC] norbert at php dot net

Please see Request #5703 which includes a patch for this bug too.