Created
December 13, 2013 21:29
-
-
Save will-in-wi/7951652 to your computer and use it in GitHub Desktop.
Test case for PHP serialization bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HelloWorld implements Serializable { | |
public $test; | |
public function __construct($str) | |
{ | |
$this->test = $str; | |
} | |
public function serialize() | |
{ | |
$simple = null; | |
$simple = new Simple(); | |
$simple->test = $this->test; | |
return serialize($simple); | |
} | |
public function unserialize($str) | |
{ | |
$simple = unserialize($str); | |
$this->test = $simple->test; | |
} | |
} | |
class Simple | |
{ | |
public $test; | |
} | |
$list = array( | |
new HelloWorld('str1'), | |
new HelloWorld('str2'), | |
new HelloWorld('str3'), | |
new HelloWorld('str4'), | |
new HelloWorld('str5'), | |
new HelloWorld('str6'), | |
new HelloWorld('str7'), | |
new HelloWorld('str8'), | |
new HelloWorld('str9'), | |
); | |
$str = serialize($list); | |
echo $str . "\n"; | |
// var_dump(unserialize($str)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment