ID: 35895
User updated by: f dot hardy at origami-systems dot com
Reported By: f dot hardy at origami-systems dot com
-Status: No Feedback
+Status: Open
Bug Type: Scripting Engine problem
Operating System: Freebsd 6
PHP Version: 5.1.2
New Comment:
Bug is always alive in php 5.1.5 under freebsd 6.0.
Previous Comments:
------------------------------------------------------------------------
[2006-06-18 17:43:46] jona at oismail dot com
Reproduced on Windows 2000 when using __sleept() with aggregated
objects as private memembers.
The bug has been reproduced in both PHP 5.2-dev (from link below) and
PHP 5.1.4.
The following script can be used to reproduce the error:
<?php
class TestParent
{
private $parentPrivateVar;
protected $parentProtectedVar;
public $parentPublicVar;
public function __construct($private, $protected, $public)
{
$this->parentPrivateVar = $private;
$this->parentProtectedVar = $protected;
$this->parentPublicVar = $public;
}
function __sleep()
{
return array("parentPrivateVar", "parentProtectedVar",
"parentPublicVar");
}
}
class TestChild extends TestParent
{
private $childPrivateVar;
protected $childProtectedVar;
public $childPublicVar;
public function __construct($private, $protected, $public)
{
$this->childPrivateVar = "child_". $private;
$this->childProtectedVar = "child_". $protected;
$this->childPublicVar = "child_". $public;
parent::__construct("parent_". $private, "parent_". $protected,
"parent_". $public);
}
function __sleep()
{
return array_merge(array("childPrivateVar", "childProtectedVar",
"childPublicVar"), parent::__sleep() );
}
}
class WebSession
{
private $privateVar;
private $privateAggregatedObject;
public function __construct($private, TestChild &$o)
{
$this->privateVar = $private;
$this->privateAggregatedObject = $o;
}
public function __sleep() { return array("privateVar",
"privateAggregatedObject"); }
public function getPrivateVar() { return $this->privateVar; }
public function getObject() { return $this->privateAggregatedObject;
}
}
// Report simple running errors
error_reporting(E_ERROR | E_PARSE | E_WARNING | E_NOTICE | E_STRICT |
E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE);
// Start user session
session_start();
if(isset($_SESSION['obj_Info']) === false)
{
$_SESSION['obj_Info'] = new WebSession("private variable", new
TestChild("private", "protected", "public") );
}
echo "<pre>";
var_dump($_SESSION['obj_Info']);
echo "</pre>";
echo "<hr />";
echo "TEST: ". $_SESSION['obj_Info']->getPrivateVar() ."<br />";
echo "OBJECT: ". $_SESSION['obj_Info']->getObject() ."<br />";
echo "OBJECT PUBLIC VAR: ".
$_SESSION['obj_Info']->getObject()->childPublicVar ."<br />";
?>
GIVES THE FOLLOWING OUTPUT IN PHP 5.1.4:
object(WebSession)#1 (2) {
["privateVar:private"]=>
string(16) "private variable"
["privateAggregatedObject:private"]=>
object(TestChild)#2 (6) {
["childPrivateVar:private"]=>
string(13) "child_private"
["childProtectedVar:protected"]=>
string(15) "child_protected"
["childPublicVar"]=>
string(12) "child_public"
["parentPrivateVar:private"]=>
string(14) "parent_private"
["parentProtectedVar:protected"]=>
string(16) "parent_protected"
["parentPublicVar"]=>
string(13) "parent_public"
}
}
TEST: private variable
OBJECT: Object id #2
OBJECT PUBLIC VAR: child_public
Notice: Unknown: "parentPrivateVar" returned as member variable from
__sleep() but does not exist in Unknown on line 0
The notice is only thrown on the initial run with "parentPrivateVar" is
actually set.
The notice is not thrown if "parentPrivateVar" is null.
In PHP 5.2-dev the scrip dies line 76: echo "OBJECT: ".
$_SESSION['obj_Info']->getObject() ."<br />";
The notice is still thrown when "parentPrivateVar" is set though.
------------------------------------------------------------------------
[2006-05-31 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2006-05-23 17:54:08] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
I cannot reproduce (on Linux) using latest 5.2 CVS. Can you please try
a snapshot from the 5.2 series and let me know if it's fixed for you
there?
------------------------------------------------------------------------
[2006-05-23 17:27:58] f dot hardy at origami-systems dot com
Bug is still alive in php 5.1.4 under freebsd.
Please correct it !
------------------------------------------------------------------------
[2006-01-28 01:00:04] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/35895
--
Edit this bug report at http://bugs.php.net/?id=35895&edit=1