Mantis - Quercus
Viewing Issue Advanced Details
2910 major always 09-05-08 19:25 09-05-08 19:27
koreth  
nam  
normal  
closed 3.2.1  
fixed  
none    
none 3.2.1  
0002910: Quercus serialize/unserialize doesn't recognize protected and private field markers
<?php
class Foo {
  protected $blah = array();
  public function getBlah() { return $this->blah; }
  public function setBlah($blah) { $this->blah = $blah; }
}
$foo = new Foo();
$foo->setBlah(array(1, 2, 3));
print serialize($foo);

Plain PHP prints

    O:3:"Foo":1:{s:7:"^@*^@blah";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}}

where the "^@" is a zero byte. Quercus prints

    O:3:"Foo":1:{s:4:"blah";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}}

On unserialize, if it's fed the plain-PHP serialized object as input, Quercus doesn't populate the protected field:

<?php
class Foo {
  protected $blah = array();
  public function getBlah() { return $this->blah; }
  public function setBlah($blah) { $this->blah = $blah; }
}
$foo = unserialize("O:3:\"Foo\":1:{s:7:\"\x00*\x00blah\";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}}");
print_r($foo->getBlah());

Plain PHP prints an array with 3 elements. Quercus prints an empty array.

The same problem exists with "private" fields, which are marked by null, the class name, and another null.

Notes
(0003401)
nam   
09-05-08 19:27   
php/121r
php/1253
php/1254
php/1255