php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36422 unserialize() __autoloads invalid objects
Submitted: 2006-02-16 20:36 UTC Modified: 2006-09-08 09:10 UTC
From: tomas_matousek at hotmail dot com Assigned: colder (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.1.2 OS: WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tomas_matousek at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-02-16 20:36 UTC] tomas_matousek at hotmail dot com
Description:
------------
When unserialize calls __autoload() and this dosn't load the required class unserialize returns an object that doesn't behave like object; var_dump displays it as an object but is_object gives false.

Reproduce code:
---------------
function __autoload($class_name)
{
	
}

var_dump($o = unserialize('O:1:"X":0:{}'));
var_dump(is_object($o));

Expected result:
----------------
object(__PHP_Incomplete_Class)#1 (1) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(1) "X"
}
bool(true)




Actual result:
--------------
object(__PHP_Incomplete_Class)#1 (1) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(1) "X"
}
bool(false)




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-16 20:59 UTC] tony2001@php.net
This is expected, as object of __PHP_Incomplete_Class is actually not valid object.
Reclassified as docu problem.
 [2006-02-17 10:22 UTC] tomas_matousek at hotmail dot com
An what is it if it is not an object? Array? Some new PHP type? So, why var_dump reports is as object? 

This:
var_dump(gettype($o));
var_dump($o->__PHP_Incomplete_Class_Name);

displays:
string(6) "object"
NULL
 [2006-02-17 11:42 UTC] colder@php.net
It is an object, but not a valid one. The object is not expected to work, so is_object() will return false.

It's already stated in the user comments: http://php.net/is_object#59209
 [2006-09-08 09:10 UTC] colder@php.net
Note is now integrated in the manual.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 13:00:01 2025 UTC