From: Brion Vibber Date: Mon, 24 Nov 2008 01:58:15 +0000 (+0000) Subject: * Add guard exception in OutputPage::parse() for failure case where $wgTitle is null... X-Git-Tag: 1.31.0-rc.0~44211 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=2d5024f4d7e9cab95ca2125e8b5d082b654659cd;p=lhc%2Fweb%2Fwiklou.git * Add guard exception in OutputPage::parse() for failure case where $wgTitle is null; that causes a fatal error which doesn't show a backtrace if we don't catch it here. * 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() --- diff --git a/includes/Import.php b/includes/Import.php index 7bd44fae4f..2fac1f9364 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -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; } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 71b4f01275..dcd5c309be 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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,