From 156bcbec81d782627ee88c404c8cf8adad854a14 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Tue, 7 Apr 2015 01:41:33 +0000 Subject: [PATCH] Mostly revert "Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()" This broke a few things, and the debug line was basically pointless. Instead, continue to only throw an exception if $text is an object, but only warn if it's otherwise not a string. This reverts commit 372ded2fea436bf0e61318991f903d61bde26366. Change-Id: I060da9191cdbd00c4873caba875bfb77c917bcd7 --- includes/Title.php | 6 ++++-- includes/libs/MapCacheLRU.php | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 9868b2e8d6..bf0fb8e1fd 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -260,8 +260,10 @@ class Title { * @return Title|null Title or null on an error. */ public static function newFromText( $text, $defaultNamespace = NS_MAIN ) { - if ( !is_string( $text ) ) { - throw new InvalidArgumentException( 'Title::newFromText given something that isn\'t a string' ); + if ( is_object( $text ) ) { + throw new InvalidArgumentException( '$text must be a string.' ); + } elseif ( !is_string( $text ) ) { + wfWarn( __METHOD__ . ': $text must be a string. This will throw an InvalidArgumentException in future.' ); } $cache = self::getTitleCache(); diff --git a/includes/libs/MapCacheLRU.php b/includes/libs/MapCacheLRU.php index b0cb078ce7..0b6db32ef9 100644 --- a/includes/libs/MapCacheLRU.php +++ b/includes/libs/MapCacheLRU.php @@ -74,11 +74,7 @@ class MapCacheLRU { * @return bool */ public function has( $key ) { - if ( is_string( $key ) || is_integer( $key ) ) { - return array_key_exists( $key, $this->cache ); - } - wfWarn( __METHOD__ . ": Key passed isn't a string or an integer.", 2 ); - return false; + return array_key_exists( $key, $this->cache ); } /** -- 2.20.1