From: str at strgt dot cjb dot net
Operating system: Linux
PHP version: Irrelevant
PHP Bug Type: Class/Object related
Bug description: session_start() destroys my object
Description:
------------
This is a weird bug, because I do only get it in some browsers.
It works fine in IExplorer, links, but not in Konqueror. All
browsers are "cookies enable". I have a class, with some
vars. When I use session_start in a class->function, i cannot
access $this nor $this->vars
I read some similar bugs are in php4.0 and solved in 4.1.0 and
I have 4.1.2
Reproduce code:
---------------
class PayUser {
var $pay_user, $passwd, $ses_id, $db, $new;
function PayUser($id) {
include_once("base.php"); // this is where i create $db
$this->db = $db;
$select = $this->db->exec("SELECT * from pay_users where
p_user='$id'"); // this means $this->db exists and it works
/// code omited..
}
function login($pass) {
// print_r($this) // before the session_start() prints me the object
session_start();
print_r($this) /// after session_start() $this is not asigned
$sid = session_id();
$sql = "UPDATE pay_users SET ses_id='$sid' where
p_user='".$this->pay_user."'";
$this->db->exec($sql); // Fatal error: Call to a member function on
a non-object in this line... because $this does not exist
// more code omited
Expected result:
----------------
in the print($this) i should expect to print
payuser Object (
[db] => database Object (
[con] => adodb_postgres7 Object (
[databaseType] => postgres7
[hasLimit] => 1
[ansiOuter] => 1
[dataProvider] => postgres...
and the $this->db->exec($sql); should be executed, not to
give the Fatal error: Call to a member function on a non-object
in this line
Actual result:
--------------
the error... and the $this is lost...
--
Edit bug report at http://bugs.php.net/?id=25706&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25706&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25706&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25706&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25706&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25706&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25706&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25706&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25706&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25706&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25706&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25706&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25706&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25706&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25706&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25706&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25706&r=float