From 7d12b7b72c2060c58b6bd0759b80d985bb9431be Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 24 May 2012 16:42:26 +0200 Subject: [PATCH] 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 --- includes/Title.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } -- 2.20.1