Add some casts for sanity before BagOStuff::add() calls
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 26 Jun 2014 23:25:31 +0000 (16:25 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 26 Jun 2014 23:25:31 +0000 (16:25 -0700)
Change-Id: I6ecb609c88e4fc1ef614e94c551199bd610ca360

includes/objectcache/BagOStuff.php
includes/utils/UIDGenerator.php

index 56f1be2..dca5f32 100644 (file)
@@ -338,7 +338,7 @@ abstract class BagOStuff {
         */
        public function incrWithInit( $key, $ttl, $value = 1, $init = 1 ) {
                return $this->incr( $key, $value ) ||
-                       $this->add( $key, $init, $ttl ) || $this->incr( $key, $value );
+                       $this->add( $key, (int)$init, $ttl ) || $this->incr( $key, $value );
        }
 
        /**
index e2013b0..0ce90c1 100644 (file)
@@ -285,7 +285,7 @@ class UIDGenerator {
                if ( $cache ) {
                        $counter = $cache->incr( $bucket, $count );
                        if ( $counter === false ) {
-                               if ( !$cache->add( $bucket, $count ) ) {
+                               if ( !$cache->add( $bucket, (int)$count ) ) {
                                        throw new MWException( 'Unable to set value to ' . get_class( $cache ) );
                                }
                                $counter = $count;