From: daniel Date: Thu, 24 May 2012 14:42:26 +0000 (+0200) Subject: Adding sanity check to Title::isRedirect(). X-Git-Tag: 1.31.0-rc.0~23431^2~1 X-Git-Url: http://git.cyclocoop.org//%27http:/code.google.com/p/ie7-js//%27?a=commitdiff_plain;h=7d12b7b72c2060c58b6bd0759b80d985bb9431be;p=lhc%2Fweb%2Fwiklou.git Adding sanity check to Title::isRedirect(). isRedirect() assumes that the LinkCache already contains information about this title. If that is not the case, it currently returns false, even though it just doesn't know whether this link is a redirect. The new check asserts the assumption that this title is already known to the link cache. Amend: use Exception instead of assert() Change-Id: Id3ad2d4e140b270b1f5ca1f7af9b3320cffff5a2 --- diff --git a/includes/Title.php b/includes/Title.php index cf428f918b..c470cb5a99 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2817,7 +2817,13 @@ class Title { return $this->mRedirect = false; } $linkCache = LinkCache::singleton(); - $this->mRedirect = (bool)$linkCache->getGoodLinkFieldObj( $this, 'redirect' ); + $cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' ); + + if ( $cached === null ) { # check the assumption that the cache actually knows about this title + throw new MWException( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() ); + } + + $this->mRedirect = (bool)$cached; return $this->mRedirect; }