From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 4.2.3
PHP Bug Type: Class/Object related
Bug description: Nonsymetric data syncronization with references
The following script creates a class which should become a class for
session-handling
<?php
class my_sess {
var $const = 0;
function my_sess () {
echo 'Constructor'."\n";
echo (++$this->const)."<br>\n";
session_set_save_handler (
array(&$this, 'open'),
array(&$this, 'close'),
array(&$this, 'read'),
array(&$this, 'write'),
array(&$this, 'destroy'),
array(&$this, 'gc')
);
session_start ();
}
function open () {
echo 'open'."\n";
echo (++$this->all)."<br>\n";
}
function close () {
echo 'close'."\n";
echo (++$this->all)."<br>\n";
}
function read () {
echo 'read'."\n";
echo (++$this->all)."<br>\n";
}
function write () {
echo 'write'."\n";
echo (++$this->all)."<br>\n";
}
function destroy () {
echo 'destroy'."\n";
echo (++$this->all)."<br>\n";
}
function gc () {
echo 'gc'."\n";
echo (++$this->all)."<br>\n";
}
function set () {
echo 'set'."\n";
echo (++$this->all)."<br>\n";
}
}
$session = new my_sess ();
echo '------------'."<br>\n";
$session->set ();
$session->set ();
$session->set ();
echo '------------'."<br>\n";
session_write_close ();
?>
If you run this script you get the following output:
---------------------------------------------------------
Constructor 1
Warning: Cannot send session cache limiter - headers already sent (output
started at /data/here/htdocs/versuch2.php:6) in
/data/here/htdocs/versuch2.php on line 16
open 1
read 2
------------
set 3
set 4
set 5
------------
write 3
close 4
-------------------------------------------------------
whereas you would expect
--------------------------------------------------------
Constructor 1
Warning: Cannot send session cache limiter - headers already sent (output
started at /data/here/htdocs/versuch2.php:6) in
/data/here/htdocs/versuch2.php on line 16
open 1
read 2
------------
set 3
set 4
set 5
------------
write 6
close 7
--------------------------------------------------------
It seems like there are two instances of the class hanging around. But how
they relate to each other is a mystery.
--
Edit bug report at http://bugs.php.net/?id=20520&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20520&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20520&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20520&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20520&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20520&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20520&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20520&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20520&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20520&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20520&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20520&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20520&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20520&r=isapi