PEAR is archived and read-only

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

Home » Database » DB » Bug #3993

parameter new_link isn't a valid parameter for mysql_pconnect

Details

Submitted2005-03-29 13:11 UTC
Fromyoghoyogho at fastmail dot fm
Assigneddanielc
StatusClosed
PackageDB
PHP VersionIrrelevant
OSLinux FreeBSD
Roadmaps(Not assigned)

Comments

[2005-03-29 13:11 UTC] yoghoyogho at fastmail dot fm

Description:
------------
in lines 216-222 in mysql.php it says:

------------------------------------------
if (isset($dsn['new_link'])
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
{
$params[] = true;
} else {
$params[] = false;
}
------------------------------------------

The new_link parameter became available in PHP 4.2.0 for mysql_connect. But it isn't a parameter that is available for mysql_pconnect. I suggest this code fix:

------------------------------------------
if (!$persistent && version_compare(phpversion(), $this->features['new_link'], '>=')) {
if (isset($dsn['new_link'])
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
{
$params[] = true;
} else {
$params[] = false;
}
}
------------------------------------------

For reference compare
http://www.php.net/mysql_pconnect
with
http://www.php.net/mysql_connect

and search for new_link

[2005-03-29 14:53 UTC] yoghoyogho at fastmail dot fm

Thanks for your quick response, danielc. Unfortunately, the fix you've added in the CVS doesn't resolve this bug.

The way it's coded now, there will be a parameter added to $params, regardless of it's value (either true or false). What I was argumenting for was that this parameter shouldn't be added if mysql_pconnect is used.
So AROUND the if-branch should be a check that ensures that mysql_connect is used.

My suggestion is to remove !$persistent from the inner if-branch and make it an outer if-branch like so:

if (!$persistent) {
if (isset($dsn['new_link']) && ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
{
$params[] = true;
} else {
$params[] = false;
}
}

This way the parameter doesn't end up in mysql_pconnect, thus shifting the value of client_flags out of reach.

I also added the version_compare because in the $features array (in line 76) the item 'new_link'=>'4.2.0' was available. So if that value is there, why not use it? :-)

So that's were my first code fix suggestion came from.

[2005-03-29 15:26 UTC] yoghoyogho at fastmail dot fm

thanks danielc