Fix argument handling in MultiWriteBagOStuff::get()
[lhc/web/wiklou.git] / includes / objectcache / SqlBagOStuff.php
index c57c9fb..e08fec9 100644 (file)
@@ -220,12 +220,7 @@ class SqlBagOStuff extends BagOStuff {
                }
        }
 
-       /**
-        * @param string $key
-        * @param mixed $casToken [optional]
-        * @return mixed
-        */
-       public function get( $key, &$casToken = null ) {
+       public function get( $key, &$casToken = null, $flags = 0 ) {
                $values = $this->getMulti( array( $key ) );
                if ( array_key_exists( $key, $values ) ) {
                        $casToken = $values[$key];
@@ -234,11 +229,7 @@ class SqlBagOStuff extends BagOStuff {
                return false;
        }
 
-       /**
-        * @param array $keys
-        * @return array
-        */
-       public function getMulti( array $keys ) {
+       public function getMulti( array $keys, $flags = 0 ) {
                $values = array(); // array of (key => value)
 
                $keysByTable = array();
@@ -370,37 +361,7 @@ class SqlBagOStuff extends BagOStuff {
         * @return bool
         */
        public function set( $key, $value, $exptime = 0 ) {
-               list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
-               try {
-                       $db = $this->getDB( $serverIndex );
-                       $exptime = intval( $exptime );
-
-                       if ( $exptime < 0 ) {
-                               $exptime = 0;
-                       }
-
-                       if ( $exptime == 0 ) {
-                               $encExpiry = $this->getMaxDateTime( $db );
-                       } else {
-                               $exptime = $this->convertExpiry( $exptime );
-                               $encExpiry = $db->timestamp( $exptime );
-                       }
-                       // (bug 24425) use a replace if the db supports it instead of
-                       // delete/insert to avoid clashes with conflicting keynames
-                       $db->replace(
-                               $tableName,
-                               array( 'keyname' ),
-                               array(
-                                       'keyname' => $key,
-                                       'value' => $db->encodeBlob( $this->serialize( $value ) ),
-                                       'exptime' => $encExpiry
-                               ), __METHOD__ );
-               } catch ( DBError $e ) {
-                       $this->handleWriteError( $e, $serverIndex );
-                       return false;
-               }
-
-               return true;
+               return $this->setMulti( array( $key => $value ), $exptime );
        }
 
        /**
@@ -761,6 +722,8 @@ class SqlBagOStuff extends BagOStuff {
         * @param int $serverIndex
         */
        protected function markServerDown( $exception, $serverIndex ) {
+               unset( $this->conns[$serverIndex] ); // bug T103435
+
                if ( isset( $this->connFailureTimes[$serverIndex] ) ) {
                        if ( time() - $this->connFailureTimes[$serverIndex] >= 60 ) {
                                unset( $this->connFailureTimes[$serverIndex] );