#23354 [NEW]: Use of variable before registration problem
From: bill dot macallister at prideindustries dot com
Operating system: Linux 2.4.18-27.7.xsmp
PHP version: 4.3.1
PHP Bug Type: *General Issues
Bug description: Use of variable before registration problem
This is as much a change in behavior as anything, but the
specific failure seems to indicate a deeper problem.
We have an application that uses out own session save handler
to store session data in a MySQL database. This application
has been in use on a 4.2.1 system for months now. When I
upgraded our test system to 4.3.1 we started getting failures.
The exact error was a MySQL connection failure because of
bad authentication credentials. The error report indicated
that the connection attempt was for webuser@localhost. Our
Apache server runs as webuser so this is the default user.
The code generating this message is:
$mysql_host = 'mysql-master';
$mysql_user = 'phpuser';
$mysql_pass = 'phppass';
$mysql_db = 'php_sessions';
if ($cnx = mysql_connect ($mysql_host,
$mysql_user,
$mysql_pass)) {
if ($db = mysql_select_db($mysql_db, $cnx)) {
$ret = $cnx;
}
}
So, the error message really is bogus or PHP's heap is
corrupt.
It turns out that I was able to make the error go away
by changing the code:
$s_user_id = $user_data["user_id"];
session_register("s_user_id");
to:
session_register("s_user_id");
$s_user_id = $user_data["user_id"];
It appears that in 4.2.1 you can use variables before you
register then and in 4.3.1 you cannot.
The 4.3.1 behavior is at least a bug in that PHP silently
accepts the invalid instruction sequence and corrupts its
environment so that completely unrelated parts of the
script will fail. If registration is required before use
I would really like to see session_register complain if
you try and do it wrong.
Bill
--
Edit bug report at http://bugs.php.net/?id=23354&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23354&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23354&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23354&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23354&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23354&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23354&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23354&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23354&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23354&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23354&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23354&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23354&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23354&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23354&r=gnused
Thread (16 messages)
- bill dot macallister at prideindustries dot com
- sniper@php.net#23354 [Opn->Fbk]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Fbk->Opn]: Use of variable before registration problem
- sniper@php.net#23354 [Opn->Fbk]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Fbk->Opn]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Opn]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Opn]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Opn]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Opn]: Use of variable before registration problem
- sniper@php.net#23354 [Opn->Fbk]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Fbk->Opn]: Use of variable before registration problem
- sniper@php.net#23354 [Opn->Csd]: Use of variable before registration problem
- bill dot macallister at prideindustries dot com#23354 [Csd]: Use of variable before registration problem
- downsize at edwardsconsultants dot com#23354 [Com]: Use of variable before registration problem
- gary at akos dot net#23354 [Com]: Use of variable before registration problem
- avermapub at yahoo dot com#23354 [Com]: Use of variable before registration problem