PEAR is archived and read-only

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

Home » Database » DB » Bug #1973

sybase_connect call not backward-compatible

Details

Request #1973sybase_connect call not backward-compatible
Submitted2004-07-24 13:06 UTC
Fromsmith at xml-doc dot org
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.1.2
OSSolaris
Roadmaps(Not assigned)

Comments

[2004-07-24 13:06 UTC] smith at xml-doc dot org

Description:
------------
I'm using DB 1.6.5 with PHP 4.1.2 and PEAR 1.3.1.
(Yes, I know that PHP 4.1.2 is old and not supported, but
I have an app running on a company server for which I
am not the admin. If filed this under PHP version =
'irrelevant' just to be able to get it logged and so
that it will show up in searches, to help out other
people who might run into the same problem.)

The good news is that DB 1.6.5 seems mostly to work fine
with PHP 4.1.2 (after including the the is_a() function
from PHP-Compat), except for connecting with the sybase
backend.

The problem is that in line 104 of DB/sybase.php, there's a
call to sybase_connect with 5 arguments. As far as I can
tell, the PHP 4.1.2 sybase_connect function does not take
5 arguments. I think it only takes 4, though I'm not sure
what the 4th argument is (whether it's a charset value
or an appname value).

But if the code were altered so that the charset and appname
args (even empty strings) where not included in the call
if they had no values, it would make it backward compatible
with PHP 4.1.2.

I realize backward compatibility with PHP 4.1.2 is not a
high priority. But in my testing at least, this is the only
backward-compatiblity issue that I've found with the sybase
backend. So, if it would be nice if it could be eliminated.

Reproduce code:
---------------
Call DB::connect using phptype=sybase with PHP 4.1.2

Expected result:
----------------
Should get a connection to sybase database.

Actual result:
--------------
Errors out with a message that it can't connect
to the database.

[2004-07-27 02:16 UTC] smith at xml-doc dot org

I have already patched my sybase.php to remove the 5th
param. And I understand that PHP 4.2.0 or greater is a
*stated* requirement of the current version of DB.
But, as I wrote earlier, in my testing with sybase
backend, that 5th param is the *only* thing that prevents
the sybase backend from being compatible with PHP 4.1.2

So, this is not a demand or even a request for help. It's
simply a suggestion: By including some simple logic to
add the 5th param only if it's passed to the connect call,
and otherwise only pass 4 params to the call, you can
make the sybase backend compatible with PHP 4.1.2.

If you decide not to do that, it's OK with with me. I
just figured I would take the time to suggest it.

[2004-07-27 03:28 UTC] smith at xml-doc dot org

For what it's worth, here's a patch:

--- sybase.php.ORIG 2004-07-27 12:02:31.416403000 +0900
+++ sybase.php 2004-07-27 12:17:43.608920100 +0900
@@ -100,11 +100,15 @@
$dsninfo['charset'] = isset($dsninfo['charset']) ? $dsninfo['charset'] : false;
$dsninfo['appname'] = isset($dsninfo['appname']) ? $dsninfo['appname'] : false;

- if ($interface && $dsninfo['username']) {
+ if ($interface && $dsninfo['username'] && $dsninfo['appname']) {
$conn = @$connect_function($interface, $dsninfo['username'],
$dsninfo['password'],
$dsninfo['charset'],
$dsninfo['appname']);
+ } elseif (($interface && $dsninfo['username'])) {
+ $conn = @$connect_function($interface, $dsninfo['username'],
+ $dsninfo['password'],
+ $dsninfo['charset']);
} else {
$conn = false;
}