|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-06-20 06:13 UTC] uwe at mesecke dot net
[2007-06-20 14:05 UTC] php at koterov dot ru
[2007-06-21 13:43 UTC] uwe at mesecke dot net
[2007-06-25 04:41 UTC] tony2001 at phpclub dot net
[2007-06-26 16:53 UTC] uwe at mesecke dot net
[2007-10-16 08:28 UTC] ohill@php.net
[2007-10-16 09:14 UTC] uwe at mesecke dot net
[2007-10-17 14:52 UTC] mikael at synd dot info
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
Description: ------------ When a class instance is get from memcache, it is unserialized before returned. That does not work, when the __wakeup()-function of the class itself asks for another value. php is from ubuntu feisty (5.2.1-0ubuntu1.2) and php-memcache is compiled with a small patch to fix the different php include paths on ubuntu. Reproduce code: --------------- function errorCallback($host, $port) { echo "ERROR: $host:$port\n"; } $mmc = new Memcache; $mmc->addServer(/* host */ 'localhost', /* port */ 11211, /* persistent */ true, /* weight */ 10, /* timeout */ 10, /* retry time */ 1, /* status */ true, /* error callback */ 'errorCallback'); class A { } class B { protected $a; public function __construct() { $this->c = new A; } public function __sleep() { $this->c = 'a'; return array_keys(get_object_vars($this)); } public function __wakeup() { global $mmc; $this->c = $mmc->get('a'); } } $a = new A; $mmc->set('a', clone $a, 0, 0); $b = new B; $mmc->set('b', clone $b, 0, 0); $c = $mmc->get('b'); var_dump($c); Expected result: ---------------- The var_dump($c) should print a string representation of an instance of class B... Actual result: -------------- the line "$c = $mmc-get('b')" seems to call the error callback function and returns "false" (object not found) uwe@harry:~$ php mmctest.php ERROR: localhost:11211 bool(false) the following is the memcached output with commandline argument -vv: <32 new client connection <32 set a 1 0 12 >32 STORED <32 set b 1 0 41 >32 STORED <32 get b >32 sending key b >32 END <32 get a >32 sending key a >32 END <32 connection closed. last thing is the trace log from xdebug: TRACE START [2007-06-19 19:09:34] 0.0012 64588 -> {main}() /home/uwe/mmctest.php:0 0.0014 65072 -> Memcache->addserver(string(9), long, bool, long, long, long, bool, string(13)) /home/uwe/mmctest.php:9 >=> TRUE 0.0017 65592 -> Memcache->set(string(1), class A, long, long) /home/uwe/mmctest.php:38 >=> TRUE 0.0027 66304 -> B->__construct() /home/uwe/mmctest.php:40 >=> NULL 0.0028 66692 -> Memcache->set(string(1), class B, long, long) /home/uwe/mmctest.php:41 0.0029 66780 -> B->__sleep() /home/uwe/mmctest.php:0 0.0029 66852 -> get_object_vars(class B) /home/uwe/mmctest.php:27 >=> array ('a' => NULL, 'c' => 'a') 0.0031 67076 -> array_keys(array(2)) /home/uwe/mmctest.php:27 >=> array (0 => 'a', 1 => 'c') >=> array (0 => 'a', 1 => 'c') >=> TRUE 0.0035 67420 -> Memcache->get(string(1)) /home/uwe/mmctest.php:43 0.0037 75644 -> B->__wakeup() /home/uwe/mmctest.php:0 0.0037 75644 -> Memcache->get(string(1)) /home/uwe/mmctest.php:33 >=> FALSE >=> NULL 0.0041 67436 -> errorCallback(string(9), long) /home/uwe/mmctest.php:0 >=> NULL >=> FALSE 0.0048 67684 -> var_dump(bool) /home/uwe/mmctest.php:45 >=> NULL >=> 1 0.0054 25208 TRACE END [2007-06-19 19:09:34]