From 126f66d95547aee888bd06c1307557d340f4a5a5 Mon Sep 17 00:00:00 2001 From: Tyler Anthony Romeo Date: Fri, 17 May 2013 12:10:31 +0000 Subject: [PATCH] Fix return type of MessageCache::getMsgFromNamespace for existing Functions expect the message cache to return a string if a message exists, even empty, and false if it does not exist. This adds casting to the substr() function, which would return false for existing messages that were just blank. Bug: 14176 Change-Id: Id91914a3701fe53f1e2e894824512489392c628b --- RELEASE-NOTES-1.22 | 3 +++ includes/cache/MessageCache.php | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 4f33548aa1..38b2cbdad5 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -143,6 +143,9 @@ production. * (bug 48294) API: Fix chunk upload async mode. * (bug 46749) Broken files tracking category removed from pages if an image with that name is uploaded. +* (bug 14176) System messages that are empty were previously incorrectly treated + as non-existent, causing a fallback to the default. This stopped users from + overriding system messages to make them blank. === API changes in 1.22 === * (bug 46626) xmldoublequote parameter was removed. Because of a bug, the diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 7dc8d05b65..fcefc065f1 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -865,14 +865,16 @@ class MessageCache { * * @param string $title Message cache key with initial uppercase letter. * @param string $code Code denoting the language to try. - * @return string|bool False on failure + * @return string|bool The message, or false iff it does not exist or on error */ function getMsgFromNamespace( $title, $code ) { $this->load( $code ); if ( isset( $this->mCache[$code][$title] ) ) { $entry = $this->mCache[$code][$title]; if ( substr( $entry, 0, 1 ) === ' ' ) { - return substr( $entry, 1 ); + // The message exists, so make sure a string + // is returned. + return (string)substr( $entry, 1 ); } elseif ( $entry === '!NONEXISTENT' ) { return false; } elseif ( $entry === '!TOO BIG' ) { @@ -895,7 +897,9 @@ class MessageCache { if ( $entry ) { if ( substr( $entry, 0, 1 ) === ' ' ) { $this->mCache[$code][$title] = $entry; - return substr( $entry, 1 ); + // The message exists, so make sure a string + // is returned. + return (string)substr( $entry, 1 ); } elseif ( $entry === '!NONEXISTENT' ) { $this->mCache[$code][$title] = '!NONEXISTENT'; return false; -- 2.20.1