Merge "Minor PECL client fixes"
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 15 May 2012 08:38:54 +0000 (08:38 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 15 May 2012 08:38:54 +0000 (08:38 +0000)
includes/objectcache/BagOStuff.php
includes/objectcache/MemcachedPeclBagOStuff.php

index cdb66c4..4b06256 100644 (file)
@@ -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 );
 
index 9c43ede..2f88407 100644 (file)
@@ -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 );
+               }
        }
 
        /**