Add CollationFa
[lhc/web/wiklou.git] / includes / objectcache / RedisBagOStuff.php
index e6b3f9e..90508da 100644 (file)
@@ -65,8 +65,8 @@ class RedisBagOStuff extends BagOStuff {
         */
        function __construct( $params ) {
                parent::__construct( $params );
-               $redisConf = array( 'serializer' => 'none' ); // manage that in this class
-               foreach ( array( 'connectTimeout', 'persistent', 'password' ) as $opt ) {
+               $redisConf = [ 'serializer' => 'none' ]; // manage that in this class
+               foreach ( [ 'connectTimeout', 'persistent', 'password' ] as $opt ) {
                        if ( isset( $params[$opt] ) ) {
                                $redisConf[$opt] = $params[$opt];
                        }
@@ -102,7 +102,7 @@ class RedisBagOStuff extends BagOStuff {
                return $result;
        }
 
-       public function set( $key, $value, $expiry = 0 ) {
+       public function set( $key, $value, $expiry = 0, $flags = 0 ) {
                list( $server, $conn ) = $this->getConnection( $key );
                if ( !$conn ) {
                        return false;
@@ -143,8 +143,8 @@ class RedisBagOStuff extends BagOStuff {
        }
 
        public function getMulti( array $keys, $flags = 0 ) {
-               $batches = array();
-               $conns = array();
+               $batches = [];
+               $conns = [];
                foreach ( $keys as $key ) {
                        list( $server, $conn ) = $this->getConnection( $key );
                        if ( !$conn ) {
@@ -153,7 +153,7 @@ class RedisBagOStuff extends BagOStuff {
                        $conns[$server] = $conn;
                        $batches[$server][] = $key;
                }
-               $result = array();
+               $result = [];
                foreach ( $batches as $server => $batchKeys ) {
                        $conn = $conns[$server];
                        try {
@@ -187,8 +187,8 @@ class RedisBagOStuff extends BagOStuff {
         * @return bool
         */
        public function setMulti( array $data, $expiry = 0 ) {
-               $batches = array();
-               $conns = array();
+               $batches = [];
+               $conns = [];
                foreach ( $data as $key => $value ) {
                        list( $server, $conn ) = $this->getConnection( $key );
                        if ( !$conn ) {
@@ -241,7 +241,7 @@ class RedisBagOStuff extends BagOStuff {
                                $result = $conn->set(
                                        $key,
                                        $this->serialize( $value ),
-                                       array( 'nx', 'ex' => $expiry )
+                                       [ 'nx', 'ex' => $expiry ]
                                );
                        } else {
                                $result = $conn->setnx( $key, $this->serialize( $value ) );
@@ -310,7 +310,8 @@ class RedisBagOStuff extends BagOStuff {
         * @return mixed
         */
        protected function unserialize( $data ) {
-               return ctype_digit( $data ) ? intval( $data ) : unserialize( $data );
+               $int = intval( $data );
+               return $data === (string)$int ? $int : unserialize( $data );
        }
 
        /**
@@ -356,12 +357,12 @@ class RedisBagOStuff extends BagOStuff {
                                }
                        }
 
-                       return array( $server, $conn );
+                       return [ $server, $conn ];
                }
 
                $this->setLastError( BagOStuff::ERR_UNREACHABLE );
 
-               return array( false, false );
+               return [ false, false ];
        }
 
        /**