Merge "Add option to expose original sha1 in thumb url"
[lhc/web/wiklou.git] / includes / objectcache / MemcachedBagOStuff.php
index 83bee70..7d12749 100644 (file)
@@ -57,12 +57,7 @@ class MemcachedBagOStuff extends BagOStuff {
                return $params;
        }
 
-       /**
-        * @param string $key
-        * @param mixed $casToken [optional]
-        * @return mixed
-        */
-       public function get( $key, &$casToken = null ) {
+       public function get( $key, &$casToken = null, $flags = 0 ) {
                return $this->client->get( $this->encodeKey( $key ), $casToken );
        }
 
@@ -173,7 +168,10 @@ class MemcachedBagOStuff extends BagOStuff {
         * @return string
         */
        public function decodeKey( $key ) {
-               return urldecode( $key );
+               // matches %00-%20, %25, %7F (=decoded alternatives for those encoded in encodeKey)
+               return preg_replace_callback( '/%([0-1][0-9]|20|25|7F)/i', function ( $match ) {
+                       return urldecode( $match[0] );
+               }, $key );
        }
 
        /**
@@ -183,4 +181,12 @@ class MemcachedBagOStuff extends BagOStuff {
        protected function debugLog( $text ) {
                $this->logger->debug( $text );
        }
+
+       public function modifySimpleRelayEvent( array $event ) {
+               if ( array_key_exists( 'val', $event ) ) {
+                       $event['flg'] = 0; // data is not serialized nor gzipped (for memcached driver)
+               }
+
+               return $event;
+       }
 }