RE: visibility + unserialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can you please example code because I simulated the similar thing and it works fine here

<?php
class A {
	protected $x = '12345';
	protected $y = '12345';
	function __construct() {
		
	}
	
	public function Hello(){
		echo Hello2;
	}
	
}
echo "<pre>";
$a = new A();
echo serialize($a);
print_r($a);
print_r(unserialize(serialize($a)));

?>

O/P :
O:1:"A":2:{s:4:"�*�x";s:5:"12345";s:4:"�*�y";s:5:"12345";}A Object
(
    [x:protected] => 12345
    [y:protected] => 12345
)
A Object
(
    [x:protected] => 12345
    [y:protected] => 12345
)

I think that’s perfectly fine.
Chetan Dattaram Rane
Software Engineer
 
 

-----Original Message-----
From: Ted Wood [mailto:ted-talks@xxxxxxxxxxxxx] 
Sent: Monday, May 26, 2008 8:56 PM
To: php-general@xxxxxxxxxxxxx
Subject:  visibility + unserialization


I have a 4 year old framework that serializes objects and stores them  
in the database. It is now going PHP 5-only, so I began to add  
visibility to the class definitions of the serialized objects.  
However, then things didn't work properly after objects stored [before  
the visibility was added] were unserialized. For example, each  
protected field ended up creating two fields, with one followed by  
":protected".

Expected Result:
----------------------

object(Foo) {
  ["bar"]=>
  string(0) "banana"
}

Actual Result:
----------------------

object(Foo) {
  ["bar:protected"]=>
  string(0) ""
  ["bar"]=>
   string(6) "banana"
}


Anybody run into this, or can explain why this might be and how I can  
avoid it?

Thanks,

~Ted


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux