X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flibs%2FMapCacheLRU.php;h=db6869bd5328a51fbf1f145eb91ad1500b9b24b4;hp=2f5a454f5ddbe3880b7d86d4715351d9ed115314;hb=64b83bdb3afd0ee4f8fc1893a865409c198e601e;hpb=1dd2e07276e1deaf431ddb01c92111038f9e2cd6 diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index 2f5a454f5d..db6869bd53 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -58,7 +58,7 @@ class MapCacheLRU { * @return void */ public function set( $key, $value ) { - if ( array_key_exists( $key, $this->cache ) ) { + if ( $this->has( $key ) ) { $this->ping( $key ); } elseif ( count( $this->cache ) >= $this->maxCacheKeys ) { reset( $this->cache ); @@ -75,6 +75,9 @@ class MapCacheLRU { * @return bool */ public function has( $key ) { + if ( !is_int( $key ) && !is_string( $key ) ) { + throw new MWException( __METHOD__ . ' called with invalid key. Must be string or integer.' ); + } return array_key_exists( $key, $this->cache ); } @@ -87,7 +90,7 @@ class MapCacheLRU { * @return mixed Returns null if the key was not found */ public function get( $key ) { - if ( !array_key_exists( $key, $this->cache ) ) { + if ( !$this->has( $key ) ) { return null; }