X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flibs%2FMapCacheLRU.php;h=3a549af7af5f78908537691c660c282b87c9a5be;hb=7585985a463964d56ebb4b56b31c467fd98a7684;hp=864880aba307d9d896eef591517a5982ef899b80;hpb=6c2a31bbf5b2cf8cfcbd4f9df382217d69b5e18f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index 864880aba3..3a549af7af 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -141,7 +141,7 @@ class MapCacheLRU implements IExpiringStore, Serializable { public function has( $key, $maxAge = 0.0 ) { if ( !is_int( $key ) && !is_string( $key ) ) { throw new UnexpectedValueException( - __METHOD__ . ' called with invalid key. Must be string or integer.' ); + __METHOD__ . ': invalid key; must be string or integer.' ); } if ( !array_key_exists( $key, $this->cache ) ) { @@ -183,8 +183,15 @@ class MapCacheLRU implements IExpiringStore, Serializable { $this->set( $key, [], $initRank ); } + if ( !is_int( $field ) && !is_string( $field ) ) { + throw new UnexpectedValueException( + __METHOD__ . ": invalid field for '$key'; must be string or integer." ); + } + if ( !is_array( $this->cache[$key] ) ) { - throw new UnexpectedValueException( "The value of '$key' is not an array." ); + $type = gettype( $this->cache[$key] ); + + throw new UnexpectedValueException( "The value of '$key' ($type) is not an array." ); } $this->cache[$key][$field] = $value; @@ -199,6 +206,12 @@ class MapCacheLRU implements IExpiringStore, Serializable { */ public function hasField( $key, $field, $maxAge = 0.0 ) { $value = $this->get( $key ); + + if ( !is_int( $field ) && !is_string( $field ) ) { + throw new UnexpectedValueException( + __METHOD__ . ": invalid field for '$key'; must be string or integer." ); + } + if ( !is_array( $value ) || !array_key_exists( $field, $value ) ) { return false; }