File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / serialize / bug21957.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:04 2012 UTC (12 years, 8 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Bug #21957 (serialize() mangles objects with __sleep)
--FILE--
<?php 
class test
{
	public $a, $b;

	function test()
	{
		$this->a = 7;
		$this->b = 2;
	}

	function __sleep()
	{
		$this->b = 0;
	}
}

$t['one'] = 'ABC';
$t['two'] = new test();

var_dump($t);

$s =  @serialize($t);
echo $s . "\n";

var_dump(unserialize($s));
?>
--EXPECT--
array(2) {
  ["one"]=>
  string(3) "ABC"
  ["two"]=>
  object(test)#1 (2) {
    ["a"]=>
    int(7)
    ["b"]=>
    int(2)
  }
}
a:2:{s:3:"one";s:3:"ABC";s:3:"two";N;}
array(2) {
  ["one"]=>
  string(3) "ABC"
  ["two"]=>
  NULL
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>