ID:               31502
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kubis at pawouk dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         WDDX related
 Operating System: WinXP SP2
 PHP Version:      5.0.3
 New Comment:

Please try using this CVS snapshot:

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




Previous Comments:
------------------------------------------------------------------------

[2005-01-12 13:57:07] petr at mudroch dot net

It seems that the problem appears when the wddx serializer tries to
serialize and then deserialize objects with private members; private
members are not serialized and the deserialized values of private
members are NULL

with session.serialize_handler = wddx in php.ini try this and then look
at file, in which session data are stored

---
session_start();
class Petr {
        private $priv;
        public $pub;
        protected  $prot;
        public $pavel;
        
        function __construct() {
                        $this->priv = "private";
                        $this->pub = "public";
                        $this->prot = "protected";
                        $this->pavel = new Pavel();
        }
}

class Pavel {
        private $priv;
        public $pub;
        protected   $prot;
        
        function __construct() {
                        $this->priv = "private";
                        $this->pub = "public";
                        $this->prot = "protected";
        }
}

$petr = new Petr();

$_SESSION['test'] = $petr;
---

you will see

<wddxPacket version='1.0'><header/><data><struct><var
name='test'><struct><var
name='php_class_name'><string>Petr</string></var><var
name=''><string>private</string></var><var
name='pub'><string>public</string></var><var
name=''><string>protected</string></var><var name='pavel'><struct><var
name='php_class_name'><string>Pavel</string></var><var
name=''><string>private</string></var><var
name='pub'><string>public</string></var><var
name=''><string>protected</string></var></struct></var></struct></var></struct></data></wddxPacket>

---

protected and private members are not serialized correctly - only value
of variable, nor its name, is serialized

------------------------------------------------------------------------

[2005-01-12 13:15:38] kubis at pawouk dot net

once more the __wakeup() function; i messed it up:

function __wakeup(){
   $this->logger->logfile.... // you won't find '/tmp/user.log' here,
you won't find the $logtype variable at all.
}

------------------------------------------------------------------------

[2005-01-12 02:15:32] kubis at pawouk dot net

Description:
------------
I have found that sometimes if you have an object A as a member of a
another object B and your try to store the object B in session AND you
are using wddx serializer as default session serializer, after
deserialization back from session the object A in member of object B
deserializes wrong. While using the standard php serializer, all seems
working perfectly.

Reproduce code:
---------------
class Logger {
  public $logfile;
  public $logtype;
  function __construct(){
     $this->logfile = '/tmp/user.log';
  }
// some logger class implementation

}

class User {
  public $logger;

function __construct()
   $this->logger = new Logger();
}

function __wakeup(){
   $this->logger->logtype .... // you won't find '/tmp/user.log' here,
you won't find the $logtype variable at all.
}



Expected result:
----------------
I am expecting that the value of $this->logger->logtype would be the
'/tmp/user.log' string; but there is not any value at all, and it seems
there is not any member 'logfile' at all. While debugging using Zend
studio i have seen that all members of the Logger class have lost their
names; there were just some numbers.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31502&edit=1

Reply via email to