#30791 [Ver->Fbk]: overload and serialize produce unexpected behaviour

From: Date: Mon, 07 Mar 2005 20:55:45 +0000
Subject: #30791 [Ver->Fbk]: overload and serialize produce unexpected behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75062@lists.php.net to get a copy of this message
ID: 30791 Updated by: sniper@php.net Reported By: alan at akbkhome dot com -Status: Verified +Status: Feedback Bug Type: Zend Engine 2 problem -Operating System: na +Operating System: * PHP Version: 5CVS-2004-11-15 (dev) New Comment: This is what I get with latest CVS HEAD: # php5 t.php Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /home/jani/t.php on line 10 Previous Comments: ------------------------------------------------------------------------ [2005-01-13 02:13:41] alan_k@php.net Changing to verified - although it's not critical (as overload was experimental in 4.x) it is a BC break - and is a relatively unexpected behaviour.. ------------------------------------------------------------------------ [2005-01-13 02:10:25] alan at akbkhome dot com Marcus already confirmed this needs fixing - the serialize code should not end up calling __call() on overloaded objects. ------------------------------------------------------------------------ [2005-01-13 00:02:03] tony2001@php.net >If an object is overloaded (with __call()), then >serializ'ing the object will fail unless __sleep() is defined. .. or unless __call() returns Array of instance names. I'd say there is no bug, 'cos your overloaded __sleep() method indeed returns wrong data. ------------------------------------------------------------------------ [2004-11-15 09:57:51] alan at akbkhome dot com Description: ------------ If an object is overloaded (with __call()), then serializ'ing the object will fail unless __sleep() is defined. It would be far clearer to either a) - force __sleep to defined on overloaded objects (E_WARN?) b) - dont call __call() with the __sleep() request. Reproduce code: --------------- class a { public $a = 4; function __call($a,$b) { return "unknown method"; } } $b = new a; echo serialize($b); Expected result: ---------------- Warning: __sleep is not defined on an overloaded object with __call() Actual result: -------------- Warning about unexpected return value to __sleep() and an empty string output from serialize() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30791&edit=1

« previous php.bugs (#75062) next »