Deprecated useless BagOStuff::replace method
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 25 Feb 2014 21:38:15 +0000 (13:38 -0800)
committerOri.livneh <ori@wikimedia.org>
Sun, 9 Mar 2014 02:53:04 +0000 (02:53 +0000)
* Almost nothing actually uses this (one extension)
  as it doesn't really solve race conditions like merge().
* Removed subclassed versions too.

Change-Id: I4d4123afcc0576a90a3cbf1e4e6daff7ebce39c3

includes/objectcache/BagOStuff.php
includes/objectcache/MemcachedBagOStuff.php
includes/objectcache/MemcachedPeclBagOStuff.php
includes/objectcache/RedisBagOStuff.php

index 857943e..f6fe243 100644 (file)
@@ -250,8 +250,10 @@ abstract class BagOStuff {
         * @param $value mixed
         * @param $exptime int
         * @return bool success
+        * @deprecated 1.23
         */
        public function replace( $key, $value, $exptime = 0 ) {
+               wfDeprecated( __METHOD__, '1.23' );
                if ( $this->get( $key ) !== false ) {
                        return $this->set( $key, $value, $exptime );
                }
index f1644ed..87acb53 100644 (file)
@@ -107,17 +107,6 @@ class MemcachedBagOStuff extends BagOStuff {
                        $this->fixExpiry( $exptime ) );
        }
 
-       /**
-        * @param $key string
-        * @param $value int
-        * @param $exptime
-        * @return Mixed
-        */
-       public function replace( $key, $value, $exptime = 0 ) {
-               return $this->client->replace( $this->encodeKey( $key ), $value,
-                       $this->fixExpiry( $exptime ) );
-       }
-
        /**
         * Get the underlying client object. This is provided for debugging
         * purposes.
index 0c3b228..18546d4 100644 (file)
@@ -176,17 +176,6 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                return $this->checkResult( $key, parent::add( $key, $value, $exptime ) );
        }
 
-       /**
-        * @param $key string
-        * @param $value int
-        * @param $exptime
-        * @return Mixed
-        */
-       public function replace( $key, $value, $exptime = 0 ) {
-               $this->debugLog( "replace($key)" );
-               return $this->checkResult( $key, parent::replace( $key, $value, $exptime ) );
-       }
-
        /**
         * @param $key string
         * @param $value int
index 427143c..f54726f 100644 (file)
@@ -236,37 +236,6 @@ class RedisBagOStuff extends BagOStuff {
                return $result;
        }
 
-       /**
-        * Non-atomic implementation of replace(). Could perhaps be done atomically
-        * with WATCH or scripting, but this function is rarely used.
-        */
-       public function replace( $key, $value, $expiry = 0 ) {
-               $section = new ProfileSection( __METHOD__ );
-
-               list( $server, $conn ) = $this->getConnection( $key );
-               if ( !$conn ) {
-                       return false;
-               }
-               if ( !$conn->exists( $key ) ) {
-                       return false;
-               }
-
-               $expiry = $this->convertToRelative( $expiry );
-               try {
-                       if ( !$expiry ) {
-                               $result = $conn->set( $key, $this->serialize( $value ) );
-                       } else {
-                               $result = $conn->setex( $key, $expiry, $this->serialize( $value ) );
-                       }
-               } catch ( RedisException $e ) {
-                       $result = false;
-                       $this->handleException( $conn, $e );
-               }
-
-               $this->logRequest( 'replace', $key, $server, $result );
-               return $result;
-       }
-
        /**
         * Non-atomic implementation of incr().
         *