Home » Database » DB_DataObject » Bug #4168
_connect() missing return statement, performance hit
Details
| Submitted | 2005-04-17 03:35 UTC |
|---|---|
| From | jonathan at sharpmedia dot net |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-04-17 03:35 UTC] jonathan at sharpmedia dot net
Description:
------------
On line 2030 (CVS 1.349) DataObject tests if $this-
>_database_dsn_md5 is set and that the CONNECTIONS index
in the array is not empty. Next it checks if the
CONNECTIONS value is an error, if so return the error.
It tests to set _database if it isn't set... at this
point we now know that we have a valid connection, yet
execution will continue onward as if there wasn't
already a connection!
See comment in 'Reproduce code' for where return
statement should go.
Reproduce code:
---------------
...
// is it already connected ?
if ($this->_database_dsn_md5 && !empty($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
if (PEAR::isError($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
return $this->raiseError(
$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->message,
$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->code, PEAR_ERROR_DIE
);
}
if (!$this->_database) {
$this->_database = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn['database'];
}
// !!! --> return true;
}
...
// it's not currently connected!
// try and work out what to use for the dsn !