Merge "Adding sanity check to Title::isRedirect()."
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 29 May 2012 17:29:19 +0000 (17:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 29 May 2012 17:29:19 +0000 (17:29 +0000)
includes/Title.php

index 481f480..dbc19d7 100644 (file)
@@ -2825,7 +2825,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;
        }