Make sure getMulti() returns an array per the class interface
[lhc/web/wiklou.git] / includes / objectcache / MemcachedPeclBagOStuff.php
index 5a96f7b..c853bcf 100644 (file)
@@ -247,11 +247,27 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                $callback = array( $this, 'encodeKey' );
                $result = $this->client->getMulti( array_map( $callback, $keys ) );
                wfProfileOut( __METHOD__ );
+               $result = $result ?: array(); // must be an array
                return $this->checkResult( false, $result );
        }
 
-       /* NOTE: there is no cas() method here because it is currently not supported
-        * by the BagOStuff interface and other BagOStuff subclasses, such as
-        * SqlBagOStuff.
+       /**
+        * @param array $data
+        * @param int $exptime
+        * @return bool
         */
+       public function setMulti( array $data, $exptime = 0 ) {
+               wfProfileIn( __METHOD__ );
+               foreach ( $data as $key => $value ) {
+                       $encKey = $this->encodeKey( $key );
+                       if ( $encKey !== $key ) {
+                               $data[$encKey] = $value;
+                               unset( $data[$key] );
+                       }
+               }
+               $this->debugLog( 'setMulti(' . implode( ', ', array_keys( $data ) ) . ')' );
+               $result = $this->client->setMulti( $data, $this->fixExpiry( $exptime ) );
+               wfProfileOut( __METHOD__ );
+               return $this->checkResult( false, $result );
+       }
 }