From d03f51b401261b18d29c3a194dd3cff78ccf45af Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 24 Mar 2007 08:23:49 +0000 Subject: [PATCH] What if __sleep doesn't return anything, fix example (bug #40344) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@232491 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop.xml | 7 ++++--- language/oop5/magic.xml | 13 +++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/language/oop.xml b/language/oop.xml index 570a6b67ce..d9ba1927d3 100644 --- a/language/oop.xml +++ b/language/oop.xml @@ -1,5 +1,5 @@ - + Classes and Objects (PHP 4) @@ -755,11 +755,12 @@ $b->example(); being run prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. + If the method doesn't return anything then &null; is serialized and + E_NOTICE is issued. - The intended use of __sleep is to close any - database connections that object may have, committing pending + The intended use of __sleep is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which need not be saved completely. diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 52024187fa..06666abaaf 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -1,5 +1,5 @@ - + Magic Methods @@ -41,14 +41,19 @@ executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. + If the method doesn't return anything then &null; is serialized and + E_NOTICE is issued. - The intended use of __sleep is to close any - database connections that the object may have, commit pending + The intended use of __sleep is to commit pending data or perform similar cleanup tasks. Also, the function is useful if you have very large objects which do not need to be saved completely. + + The __sleep method should return the value to serialize + (usually $this), otherwise &null; is serialized. + Conversely, unserialize checks for the presence of a function with the magic name @@ -87,7 +92,7 @@ class Connection { public function __sleep() { - mysql_close($this->link); + return array('server', 'username', 'password', 'db'); } public function __wakeup()