From: daniel Date: Tue, 24 Apr 2012 14:17:20 +0000 (+0200) Subject: use ContextSource in WikiPage::getParserOutput and PoolWorkArticleView X-Git-Tag: 1.31.0-rc.0~22097^2^2~209 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=4585a974f0ce4614e256d4cb19682af4b27336c0;p=lhc%2Fweb%2Fwiklou.git use ContextSource in WikiPage::getParserOutput and PoolWorkArticleView --- diff --git a/includes/Article.php b/includes/Article.php index a2cbf4312d..a80f908f99 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -648,8 +648,9 @@ class Article extends Page { # Run the parse, protected by a pool counter wfDebug( __METHOD__ . ": doing uncached parse\n" ); + // @todo: shouldn't we be passing $this->getPage() to PoolWorkArticleView instead of plain $this? $poolArticleView = new PoolWorkArticleView( $this, $parserOptions, - $this->getRevIdFetched(), $useParserCache, $this->getContentObject() ); + $this->getRevIdFetched(), $useParserCache, $this->getContentObject(), $this->getContext() ); if ( !$poolArticleView->execute() ) { $error = $poolArticleView->getError(); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 8dab92c660..d0362484b2 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -897,9 +897,11 @@ class WikiPage extends Page { * @param $parserOptions ParserOptions to use for the parse operation * @param $oldid Revision ID to get the text from, passing null or 0 will * get the current revision (default value) + * @param $context IContextSource context for parsing + * * @return ParserOutput or false if the revision was not found */ - public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) { + public function getParserOutput( ParserOptions $parserOptions, $oldid = null, IContextSource $context = null ) { wfProfileIn( __METHOD__ ); $useParserCache = $this->isParserCacheUsed( $parserOptions, $oldid ); @@ -920,7 +922,7 @@ class WikiPage extends Page { $oldid = $this->getLatest(); } - $pool = new PoolWorkArticleView( $this, $parserOptions, $oldid, $useParserCache ); + $pool = new PoolWorkArticleView( $this, $parserOptions, $oldid, $useParserCache, null, $context ); $pool->execute(); wfProfileOut( __METHOD__ ); @@ -1191,7 +1193,7 @@ class WikiPage extends Page { * @param $sectionTitle String: new section's subject, only if $section is 'new' * @param $edittime String: revision timestamp or null to use the current revision * @return Content new complete article content, or null if error - * @deprected since 1.20, use replaceSectionContent() instead + * @deprecated since 1.20, use replaceSectionContent() instead */ public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: use replaceSectionContent() instead! wfDeprecated( __METHOD__, '1.20' ); @@ -3037,16 +3039,23 @@ class PoolWorkArticleView extends PoolCounterWork { * @param $useParserCache Boolean: whether to use the parser cache * @param $parserOptions parserOptions to use for the parse operation * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC + * @param $context IContextSource context for parsing */ - function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) { + function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null, IContextSource $context = null ) { if ( is_string($content) ) { #BC: old style call $modelName = $page->getRevision()->getContentModelName(); $format = $page->getRevision()->getContentFormat(); $content = ContentHandler::makeContent( $content, $page->getTitle(), $modelName, $format ); } + if ( is_null( $context ) ) { + $context = RequestContext::getMain(); + #XXX: clone and then set title? + } + $this->page = $page; $this->revid = $revid; + $this->context = $context; $this->cacheable = $useParserCache; $this->parserOptions = $parserOptions; $this->content = $content; @@ -3085,7 +3094,9 @@ class PoolWorkArticleView extends PoolCounterWork { * @return bool */ function doWork() { - global $wgParser, $wgUseFileCache; + global $wgUseFileCache; + + // @todo: several of the methods called on $this->page are not declared in Page, but present in WikiPage and delegated by Article. $isCurrent = $this->revid === $this->page->getLatest(); @@ -3103,7 +3114,7 @@ class PoolWorkArticleView extends PoolCounterWork { $time = - microtime( true ); // TODO: page might not have this method? Hard to tell what page is supposed to be here... - $this->parserOutput = $content->getParserOutput( $this->page->getContext(), $this->revid, $this->parserOptions ); + $this->parserOutput = $content->getParserOutput( $this->context, $this->revid, $this->parserOptions ); $time += microtime( true ); # Timing hack