* Add guard exception in OutputPage::parse() for failure case where $wgTitle is null...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 24 Nov 2008 01:58:15 +0000 (01:58 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 24 Nov 2008 01:58:15 +0000 (01:58 +0000)
* Temporarily set $wgTitle while doing article creation/edit updates during XML import. A null $wgTitle as in importDump.php caused a fatal error when special pages were transcluded if they did any parsing via OutputPage::parse()

includes/Import.php
includes/OutputPage.php

index 7bd44fa..2fac1f9 100644 (file)
@@ -209,6 +209,10 @@ class WikiRevision {
                        ) );
                $revId = $revision->insertOn( $dbw );
                $changed = $article->updateIfNewerOn( $dbw, $revision );
+               
+               # To be on the safe side...
+               $tempTitle = $GLOBALS['wgTitle'];
+               $GLOBALS['wgTitle'] = $this->title;
 
                if( $created ) {
                        wfDebug( __METHOD__ . ": running onArticleCreate\n" );
@@ -229,6 +233,7 @@ class WikiRevision {
                                $this->timestamp,
                                $revId );
                }
+               $GLOBALS['wgTitle'] = $tempTitle;
 
                return true;
        }
index 71b4f01..dcd5c30 100644 (file)
@@ -631,6 +631,9 @@ class OutputPage {
         */
        public function parse( $text, $linestart = true, $interface = false ) {
                global $wgParser, $wgTitle;
+               if( is_null( $wgTitle ) ) {
+                       throw new MWException( 'Empty $wgTitle in ' . __METHOD__ );
+               }
                $popts = $this->parserOptions();
                if ( $interface) { $popts->setInterfaceMessage(true); }
                $parserOutput = $wgParser->parse( $text, $wgTitle, $popts,