php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20520 Nonsymetric data syncronization with references
Submitted: 2002-11-20 09:49 UTC Modified: 2003-01-02 18:39 UTC
From: gerhard dot siegesmund at orange-digital dot de Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-11-20 09:49 UTC] gerhard dot siegesmund at orange-digital dot de
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-08 16:12 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2003-01-02 18:39 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC