Skip to content

Instantly share code, notes, and snippets.

@will-in-wi
Created December 13, 2013 21:29
Show Gist options
  • Save will-in-wi/7951652 to your computer and use it in GitHub Desktop.
Save will-in-wi/7951652 to your computer and use it in GitHub Desktop.
Test case for PHP serialization bug
<?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