php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26746 using unserialize in a class on the object itself
Submitted: 2003-12-30 00:51 UTC Modified: 2003-12-30 06:39 UTC
From: ken dot shin at ifrance dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5CVS-2003-12-30 (dev) OS: win2000
Private report: No CVE-ID: None
 [2003-12-30 00:51 UTC] 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"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-30 06:39 UTC] helly@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC