Don't unserialize integer reply from Redis incrBy
authorMatthew Flaschen <mflaschen@wikimedia.org>
Fri, 27 Jun 2014 22:08:23 +0000 (18:08 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Fri, 27 Jun 2014 22:24:35 +0000 (18:24 -0400)
It does not work with unserialize because RedisBagOStuff->unserialize
expects either strings of digits, or serialized strings.  A plain integer
is neither.

incr docs were incorrect, so fix and expand by copying from parent class.

Change-Id: Ifc9c7a36f221b251ceea0d9a79ae6c3ce5753dd4

includes/objectcache/RedisBagOStuff.php

index 825c77b..c7d2f13 100644 (file)
@@ -298,9 +298,9 @@ class RedisBagOStuff extends BagOStuff {
         * command. But we are constrained by the memcached-like interface to
         * return null in that case. Once the key exists, further increments are
         * atomic.
-        * @param string $key
-        * @param int $value
-        * @param bool|mixed
+        * @param string $key Key to increase
+        * @param int $value Value to add to $key (Default 1)
+        * @return int|bool New value or false on failure
         */
        public function incr( $key, $value = 1 ) {
                $section = new ProfileSection( __METHOD__ );
@@ -313,7 +313,7 @@ class RedisBagOStuff extends BagOStuff {
                        return null;
                }
                try {
-                       $result = $this->unserialize( $conn->incrBy( $key, $value ) );
+                       $result = $conn->incrBy( $key, $value );
                } catch ( RedisException $e ) {
                        $result = false;
                        $this->handleException( $conn, $e );