#26746 [Opn->Bgs]: using unserialize in a class on the object itself

From: Date: Tue, 30 Dec 2003 11:39:21 +0000
Subject: #26746 [Opn->Bgs]: using unserialize in a class on the object itself
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-52608@lists.php.net to get a copy of this message
 ID:               26746
 Updated by:       helly@php.net
 Reported By:      ken dot shin at ifrance dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: win2000
 PHP Version:      5CVS-2003-12-30 (dev)
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

In PHP5 you cannot override $this to exchange the object itself as you
could in PHP4 you can only modify the object.


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

[2003-12-30 00:51:41] ken dot shin at ifrance dot com

Description:
------------
well,

when i try to use unserialize in a class on the object itself,
that's return me an empty object, all property are set to NULL.

the code below work well with php4, but doesn't with php5.

Reproduce code:
---------------
<?php
class a {
    var $x;  
    function unS($serial) {
        $this = unserialize($serial);
    }
}

$test1 = new a;
$test1 -> x = 'blabla';
var_dump($test1);

$serial = serialize ($test1);
var_dump($serial);

$test2 = new a;
$test2->unS($serial);
//$test2 = unserialize($serial);
var_dump($test2);
?>

Expected result:
----------------
i expected the same behaviour as in php4. php5 return me the right
result when i use unserialize out of the class but return me an empty
object when i use it in the class.

actual result
-------------------------
object(a)#2 (1) {
  ["x"]=>
  NULL
}


expected result
-------------------------
object(a)#2 (1) {
  ["x"]=>
  string(7) "blabla"
}



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


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


Thread (2 messages)

« previous php.bugs (#52608) next »