From: Tim Starling Date: Tue, 15 May 2012 03:34:24 +0000 (+1000) Subject: Minor PECL client fixes X-Git-Tag: 1.31.0-rc.0~23608^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=d3fd5db2076e03bdb409c3634013ba658d019c3b;p=lhc%2Fweb%2Fwiklou.git Minor PECL client fixes * Fixed the check for igbinary presence. It's not enough for the extension to be loaded, the memcached extension also needs to be compiled with --enable-memcached-igbinary. * When delete() is attempted on a key that doesn't exist, return true, as in the other BagOStuff implementations. Change-Id: I298952f4a9925d860fa5673f632d073b1f20aa47 --- diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index cdb66c49a3..4b062567ed 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -87,7 +87,7 @@ abstract class BagOStuff { * Delete an item. * @param $key string * @param $time int Amount of time to delay the operation (mostly memcached-specific) - * @return bool success + * @return bool True if the item was deleted or not found, false on failure */ abstract public function delete( $key, $time = 0 ); diff --git a/includes/objectcache/MemcachedPeclBagOStuff.php b/includes/objectcache/MemcachedPeclBagOStuff.php index 9c43ede894..2f88407d2f 100644 --- a/includes/objectcache/MemcachedPeclBagOStuff.php +++ b/includes/objectcache/MemcachedPeclBagOStuff.php @@ -58,8 +58,8 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { $this->client->setOption( Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_PHP ); break; case 'igbinary': - if ( !extension_loaded( 'igbinary' ) ) { - throw new MWException( __CLASS__.': the igbinary extension is not loaded ' . + if ( !Memcached::HAVE_IGBINARY ) { + throw new MWException( __CLASS__.': the igbinary extension is not available ' . 'but igbinary serialization was requested.' ); } $this->client->setOption( Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY ); @@ -100,7 +100,13 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff { */ public function delete( $key, $time = 0 ) { $this->debugLog( "delete($key)" ); - return $this->checkResult( $key, parent::delete( $key, $time ) ); + $result = parent::delete( $key, $time ); + if ( $result === false && $this->client->getResultCode() === Memcached::RES_NOTFOUND ) { + // "Not found" is counted as success in our interface + return true; + } else { + return $this->checkResult( $key, $result ); + } } /**