From d3fd5db2076e03bdb409c3634013ba658d019c3b Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 15 May 2012 13:34:24 +1000 Subject: [PATCH] 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 --- includes/objectcache/BagOStuff.php | 2 +- includes/objectcache/MemcachedPeclBagOStuff.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) 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 ); + } } /** -- 2.20.1