php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19842 is_object returns FALSE on Incomplete classes
Submitted: 2002-10-10 01:55 UTC Modified: 2002-10-28 10:22 UTC
From: alan at akbkhome dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4CVS-2002-10-10 OS: linux
Private report: No CVE-ID:
 [2002-10-10 01:55 UTC] alan at akbkhome dot com
Steps to reproduce
a) generate a serialized class
eg.
class atest {
  var $t = 1;
}
$t = new atest;
$fh = fopen('/tmp/test','w');
fwrite($fh,serialize($t));
fclose($fh);
----------------------
In another file
$data = unserialize(file_get_contents('/tmp/test'));
if (!is_object($data)) {
   echo "DATA is an ".gettype($b)."!\n"; }
}

---- should output 
DATA is an object!

It's on the verge of expected behaviour, but it would be nice if it worked :)


        

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-10 02:13 UTC] alan_k@php.net
variable object variables also fail on incomplete classes:

eg. (from the example below)

$data = unserialize(file_get_contents('/tmp/test'));
$key = 't';
var_dump($data->$key); // is blank.
//however
$ar = get_object_vars($data);
echo $ar[$key]; // produces 1


 [2002-10-28 10:22 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It'll work flawlesly if you second script also contains the class defention ( class atest { var $t = 1; } ). Without it the class defenition, everything works properly with the exception of is_object, which is failing due to the class atest not being defined.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Mon May 22 15:01:40 2017 UTC