cvs: pear /Log package.xml /Log/Log mdb2.php
| From: | Jon Parise | Date: | Mon, 25 Jul 2005 04:49:10 +0000 |
| Subject: | cvs: pear /Log package.xml /Log/Log mdb2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-33283@lists.php.net to get a copy of this message | ||
jon Mon Jul 25 00:49:10 2005 EDT
Modified files:
/pear/Log package.xml
/pear/Log/Log mdb2.php
Log:
If an existing database connection is passed in via the configuration
array, or if we get an existing connection via the singleton, we weren't
creating the prepared statement object. In those two cases, we now
prepare the statement object on the first call to log(). The statement
object is freed in close().
I considered preparing the statement object is the constructor, but I
generally attempt to avoid resource allocation in handlers' constructors.
It would also put us in a situation where the user might not think to call
close() because they never called open(), which would prevent the object
from being freed. (Fortunately, PHP would eventually free that memory,
but I like this symmetry better.)
Bug: 4873
http://cvs.php.net/diff.php/pear/Log/package.xml?r1=1.85&r2=1.86&ty=u
Index: pear/Log/package.xml
diff -u pear/Log/package.xml:1.85 pear/Log/package.xml:1.86
--- pear/Log/package.xml:1.85 Sun Jul 17 23:49:47 2005
+++ pear/Log/package.xml Mon Jul 25 00:49:08 2005
@@ -14,7 +14,7 @@
</maintainers>
<release>
<version>1.9.0</version>
- <date>2005-07-17</date>
+ <date>2005-07-24</date>
<license>PHP License</license>
<state>stable</state>
<notes>Added stringToPriority() for converting priority names to PEAR_LOG_* constants.
@@ -93,7 +93,7 @@
<changelog>
<release>
<version>1.9.0</version>
- <date>2005-07-17</date>
+ <date>2005-07-24</date>
<license>PHP License</license>
<state>stable</state>
<notes>Added stringToPriority() for converting priority names to PEAR_LOG_* constants.
(Bug 2853)
http://cvs.php.net/diff.php/pear/Log/Log/mdb2.php?r1=1.1&r2=1.2&ty=u
Index: pear/Log/Log/mdb2.php
diff -u pear/Log/Log/mdb2.php:1.1 pear/Log/Log/mdb2.php:1.2
--- pear/Log/Log/mdb2.php:1.1 Mon Jul 4 21:42:05 2005
+++ pear/Log/Log/mdb2.php Mon Jul 25 00:49:10 2005
@@ -1,8 +1,8 @@
<?php
/**
- * $Header: /repository/pear/Log/Log/mdb2.php,v 1.1 2005/07/05 01:42:05 jon Exp $
+ * $Header: /repository/pear/Log/Log/mdb2.php,v 1.2 2005/07/25 04:49:10 jon Exp $
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @package Log
*/
@@ -190,11 +190,15 @@
*/
function close()
{
+ /* If we have a statement object, free it. */
+ if (is_object($this->_statement)) {
+ $this->_statement->free();
+ $this->_statement = null;
+ }
+
+ /* If we opened the database connection, disconnect it. */
if ($this->_opened && !$this->_existingConnection) {
$this->_opened = false;
- if (is_object($this->_statement)) {
- $this->_statement->free();
- }
return $this->_db->disconnect();
}
@@ -246,6 +250,14 @@
return false;
}
+ /* If we don't already have a statement object, create one. */
+ if (!is_object($this->_statement)) {
+ $this->_statement = &$this->_prepareStatement();
+ if (PEAR::isError($this->_statement)) {
+ return false;
+ }
+ }
+
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);