Home » Logging » Log » Bug #5702
sql bug when using an existing connection
Details
| Submitted | 2005-10-17 01:05 UTC |
|---|---|
| From | norbert_m at php dot net |
| Assigned | jon |
| Status | Closed |
| Package | Log |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| 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.