PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #3759

Array DSN not converted to string in PEAR::ERROR user info

Details

Submitted2005-03-09 21:23 UTC
Fromj_kimrey at yahoo dot com
Assignedaharvey
StatusClosed
PackageDB
PHP VersionIrrelevant
OSAll
Roadmaps(Not assigned)

Comments

[2005-03-09 21:23 UTC] j_kimrey at yahoo dot com

Description:
------------
If a connection fails, and the DSN was an array, the getDebugInfo() and getUserInfo() functions of the error class show '** Array' instead of the converting the DSN array data to a string.

Reproduce code:
---------------
<?php
require_once 'DB.php';

// make one of these parameters bad so that the connection
// will fail
$dsn = array(
'phptype' => "oci8",
'dbsyntax' => "oracle",
'username' => "foo",
'password' => "badpw",
'hostspec' => "bat"
);

$conn =& DB::connect($dsn); // will generate an error

// error string will have '** Array' instead of dsn array
// parameters.
print($conn->getDebugInfo());
?>

Patch by changing lines 557 - 560 in DB.php 1.7.4 to
if (DB::isError($err)) {
if (is_array($dsn)) {
$dsn['password'] = preg_replace('/./', 'x', $dsn['password']);
$err->addUserInfo(var_export($dsn, true));
} else {
$err->addUserInfo($dsn);
}
return $err;
}

Expected result:
----------------
Something similar to

... ** 'phptype' => "oci8", 'dbsyntax' => "oracle", 'username' => "foo", 'password' => "badpw", 'database' => "bar", 'hostspec' => "bat"

Actual result:
--------------
... ** Array

[2005-03-10 01:37 UTC] j_kimrey at yahoo dot com

Cool.

Feel free to use or discard the patch I provided. I'm glad I can contribute in some small way to the development of this excellent module.