jenkins-bot has submitted this change and it was merged. Change subject: Fix return type of MessageCache::getMsgFromNamespace for existing ......................................................................
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 --- M RELEASE-NOTES-1.22 M includes/cache/MessageCache.php 2 files changed, 10 insertions(+), 3 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 4f33548..38b2cbd 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -143,6 +143,9 @@ * (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 7dc8d05..fcefc06 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -865,14 +865,16 @@ * * @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 @@ 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; -- To view, visit https://gerrit.wikimedia.org/r/64277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id91914a3701fe53f1e2e894824512489392c628b Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: Daniel Friesen <dan...@nadir-seen-fire.com> Gerrit-Reviewer: Greg Grossmeier <g...@wikimedia.org> Gerrit-Reviewer: IAlex <coderev...@emsenhuber.ch> Gerrit-Reviewer: MZMcBride <w...@mzmcbride.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits