PHP4 Bug #1769 Updated: mysql() broken

From: Date: Thu, 22 Jul 1999 16:31:42 +0000
Subject: PHP4 Bug #1769 Updated: mysql() broken
Groups: php.dev 
Request: Send a blank email to php-dev+get-8984@lists.php.net to get a copy of this message
ID: 1769 User Update by: sander@pilon.com Status: Open Bug Type: MySQL related Description: mysql() broken I managed to track down and fix the mysql() bug. I have no clue who to call, so I'll just post the bug and solution right here. It's also my fist 10 minutes in the php source :) Hokay, bug description is here: http://bugs.php.net/version4/bugs.php?id=1769 What causes this fucker? Well, in mysql_db_query() there is an arguement count-check, it finds two arguements. (database,query) There, it calls php3_mysql_get_default_link(). That's our bad boy. In php3_mysql_get_default_link() it checks if we already have a mysql connection id, we dont, so it calls php3_mysql_do_connect(). In php3_mysql_do_connect() we have the real 'bug'. You see, all the time the parameters to the mysql() call are passed through the functions. So, there are STILL two arguements, and switch(ARG_COUNT(ht)) returns two. As a result of that, in the first switch tree, the first arguement (table name) is stored in the mysql 'host' variable, and the second variable (query) is stored in the mysql 'user' variable. And, obviously, that's not going to connect very well. I fixed (well, hack-fixed, cuz it can be done cleaner.) it by adding a 3rd variable to php3_mysql_do_connect(), 'usedefaults'. In php3_mysql_get_default_link() I call php3_mysql_do_connect with usedefaults = 1, all previous calls I modified so it calls with usedefaults = 0. Last modification to complete the fix is to skip the entire switch tree in the connect code if usedefaults == 1. I leave it to the experts to make a clean fix. Looking at the code, I'd say *ALL* non '*-connect' mysql functions that implicitly connect (connect to the 'default' server) are affected by this bug. Full Bug description available at: http://bugs.php.net/version4/?id=1769

« previous php.dev (#8984) next »