From 83dd6d7e3d51ef3ab91f081009cb9ccbe9b7d94b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 25 Feb 2014 13:38:15 -0800 Subject: [PATCH] Deprecated useless BagOStuff::replace method * 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 | 2 ++ includes/objectcache/MemcachedBagOStuff.php | 11 ------- .../objectcache/MemcachedPeclBagOStuff.php | 11 ------- includes/objectcache/RedisBagOStuff.php | 31 ------------------- 4 files changed, 2 insertions(+), 53 deletions(-) diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index 857943ee90..f6fe243cd1 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -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 ); } diff --git a/includes/objectcache/MemcachedBagOStuff.php b/includes/objectcache/MemcachedBagOStuff.php index f1644edbf7..87acb532ec 100644 --- a/includes/objectcache/MemcachedBagOStuff.php +++ b/includes/objectcache/MemcachedBagOStuff.php @@ -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. diff --git a/includes/objectcache/MemcachedPeclBagOStuff.php b/includes/objectcache/MemcachedPeclBagOStuff.php index 0c3b228f81..18546d4049 100644 --- a/includes/objectcache/MemcachedPeclBagOStuff.php +++ b/includes/objectcache/MemcachedPeclBagOStuff.php @@ -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 diff --git a/includes/objectcache/RedisBagOStuff.php b/includes/objectcache/RedisBagOStuff.php index 427143c328..f54726f159 100644 --- a/includes/objectcache/RedisBagOStuff.php +++ b/includes/objectcache/RedisBagOStuff.php @@ -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(). * -- 2.20.1