php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5402 unserializing "stdClass" objects gives error
Submitted: 2000-07-06 15:37 UTC Modified: 2000-07-27 21:58 UTC
From: east at canit dot se Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.1pl2 OS: Linux
Private report: No CVE-ID: None
 [2000-07-06 15:37 UTC] east at canit dot se
in PHP 4.0.1pl2 something seems to be broke regarding serializing objects of type "stdClass".
A class with an object of type "stdClass" cannot be unserialized and used.
The following example WONT work:
class Foo
{
	var $object;
	function Foo()
	{
	$object = mysql_fetch_object($result);
	}
}
/* code */
$myfoo = new MyFoo();
$s_myfoo = serialize($myfoo);
$newfoo = new MyFoo();
$newfoo = unserialize($s_myfoo);
/***************/
echo $newfoo->object->what_ever;
gives the following error
"The script tried to execute a method or access a property of an incomplete object" - even though "stdClass" definition exists and is loaded.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-06 15:50 UTC] stas at cvs dot php dot net
Works for me. Are you sure you are using 4.0.1pl2?
Try latest CVS, then.
 [2000-07-20 22:52 UTC] east at canit dot se
Tried again.
The following does not work in PHP Version 4.0.1pl2!
(works fine in 4.0.0)
System Linux heaven 2.2.16 #1 Tue Jun 13 13:58:52 CEST 2000 i586 unknown.

Exact Code (needs reloading once)
---------------------------------
class Foo
{
	var $object;
	var $str;

	function Foo()
	{
		$this->object->mytest = "testing";
		$this->object->other = "hallo";

		$this->str = "the following works";
	}
}

$myfoo = new Foo();
print("creating foo()<br>\n");

$s_myfoo = serialize($myfoo);
printf("serializing foo() = %s<br>\n", $s_myfoo);

$newfoo = new Foo();
$newfoo = unserialize($s_myfoo);
print("unserializing newfoo<br>\n");

print("printing variable...<br>\n");
printf("newfoo->str = %s<br>\n", $newfoo->str);
printf("newfoo->object->mytest = %s<br>\n", $newfoo->object->mytest);


 [2000-07-20 22:53 UTC] east at canit dot se
May need to be "reloaded" once after opening the page.

 [2000-07-23 11:09 UTC] stas at cvs dot php dot net
Works for me again. Did you try the latest CVS?
 [2000-07-27 21:58 UTC] waldschrott@php.net
works fine for me too..., try the latest CVS and send a mail to reopen if it still doesn?t work
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 06:00:01 2026 UTC