Check for bad title on redirect (ot: why can't diff understand indentation changes...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 17 Dec 2003 00:18:27 +0000 (00:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 17 Dec 2003 00:18:27 +0000 (00:18 +0000)
includes/Article.php

index 44d6a8d..fce6c59 100644 (file)
@@ -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 );
+                                                       }
                                                }
                                        }
                                }