From 71840371c45682d9ca825105b94e8131d14e3f2a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 17 Dec 2003 00:18:27 +0000 Subject: [PATCH] Check for bad title on redirect (ot: why can't diff understand indentation changes? is it so hard?) --- includes/Article.php | 49 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 44d6a8d979..fce6c59055 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -133,30 +133,31 @@ class Article { if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/", $s->cur_text, $m ) ) { $rt = Title::newFromText( $m[1] ); - - # Gotta hand redirects to special pages differently: - # Fill the HTTP response "Location" header and ignore - # the rest of the page we're on. - - if ( $rt->getInterwiki() != "" ) { - $wgOut->redirect( $rt->getFullURL() ) ; - return; - } - if ( $rt->getNamespace() == Namespace::getSpecial() ) { - $wgOut->redirect( wfLocalUrl( - $rt->getPrefixedURL() ) ); - return; - } - $rid = $rt->getArticleID(); - if ( 0 != $rid ) { - $sql = "SELECT cur_text,cur_timestamp,cur_user," . - "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}"; - $res = wfQuery( $sql, DB_READ, $fname ); - - if ( 0 != wfNumRows( $res ) ) { - $this->mRedirectedFrom = $this->mTitle->getPrefixedText(); - $this->mTitle = $rt; - $s = wfFetchObject( $res ); + if( $rt ) { + # Gotta hand redirects to special pages differently: + # Fill the HTTP response "Location" header and ignore + # the rest of the page we're on. + + if ( $rt->getInterwiki() != "" ) { + $wgOut->redirect( $rt->getFullURL() ) ; + return; + } + if ( $rt->getNamespace() == Namespace::getSpecial() ) { + $wgOut->redirect( wfLocalUrl( + $rt->getPrefixedURL() ) ); + return; + } + $rid = $rt->getArticleID(); + if ( 0 != $rid ) { + $sql = "SELECT cur_text,cur_timestamp,cur_user," . + "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}"; + $res = wfQuery( $sql, DB_READ, $fname ); + + if ( 0 != wfNumRows( $res ) ) { + $this->mRedirectedFrom = $this->mTitle->getPrefixedText(); + $this->mTitle = $rt; + $s = wfFetchObject( $res ); + } } } } -- 2.20.1