r102109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102108‎ | r102109 | r102110 >
Date:19:17, 5 November 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Use WikiPage instead of Article for doPurge(), getting raw wikitext and ParserCache access
* Use ParserOptions::newFromContext()
Modified paths:
  • /trunk/phase3/includes/api/ApiPurge.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiPurge.php
@@ -68,18 +68,18 @@
6969 $result[] = $r;
7070 continue;
7171 }
72 - $context = new DerivativeContext( $this->getContext() );
73 - $context->setTitle( $title );
74 - $article = Article::newFromTitle( $title, $context );
75 - $article->doPurge(); // Directly purge and skip the UI part of purge().
 72+
 73+ $page = WikiPage::factory( $title );
 74+ $page->doPurge(); // Directly purge and skip the UI part of purge().
7675 $r['purged'] = '';
7776
7877 if( $forceLinkUpdate ) {
7978 if ( !$user->pingLimiter() ) {
8079 global $wgParser, $wgEnableParserCache;
81 - $popts = new ParserOptions();
82 - $p_result = $wgParser->parse( $article->getContent(), $title, $popts );
8380
 81+ $popts = ParserOptions::newFromContext( $this->getContext() );
 82+ $p_result = $wgParser->parse( $page->getRawText(), $title, $popts );
 83+
8484 # Update the links tables
8585 $u = new LinksUpdate( $title, $p_result );
8686 $u->doUpdate();
@@ -88,7 +88,7 @@
8989
9090 if ( $wgEnableParserCache ) {
9191 $pcache = ParserCache::singleton();
92 - $pcache->save( $p_result, $article, $popts );
 92+ $pcache->save( $p_result, $page, $popts );
9393 }
9494 } else {
9595 $this->setWarning( $this->parseMsg( array( 'actionthrottledtext' ) ) );

Sign-offs

UserFlagDate
Nikerabbitinspected09:18, 6 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:19, 6 November 2011

What is the difference in using new parseroptions and taking it from the context?

Status & tagging log