* Use WikiPage instead of Article for doPurge(), getting raw wikitext and ParserCache...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Nov 2011 19:17:15 +0000 (19:17 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Nov 2011 19:17:15 +0000 (19:17 +0000)
* Use ParserOptions::newFromContext()

includes/api/ApiPurge.php

index 89885b3..db5d22b 100644 (file)
@@ -68,17 +68,17 @@ class ApiPurge extends ApiBase {
                                $result[] = $r;
                                continue;
                        }
-                       $context = new DerivativeContext( $this->getContext() );
-                       $context->setTitle( $title );
-                       $article = Article::newFromTitle( $title, $context );
-                       $article->doPurge(); // Directly purge and skip the UI part of purge().
+
+                       $page = WikiPage::factory( $title );
+                       $page->doPurge(); // Directly purge and skip the UI part of purge().
                        $r['purged'] = '';
 
                        if( $forceLinkUpdate ) {
                                if ( !$user->pingLimiter() ) {
                                        global $wgParser, $wgEnableParserCache;
-                                       $popts = new ParserOptions();
-                                       $p_result = $wgParser->parse( $article->getContent(), $title, $popts );
+
+                                       $popts = ParserOptions::newFromContext( $this->getContext() );
+                                       $p_result = $wgParser->parse( $page->getRawText(), $title, $popts );
 
                                        # Update the links tables
                                        $u = new LinksUpdate( $title, $p_result );
@@ -88,7 +88,7 @@ class ApiPurge extends ApiBase {
 
                                        if ( $wgEnableParserCache ) {
                                                $pcache = ParserCache::singleton();
-                                               $pcache->save( $p_result, $article, $popts );
+                                               $pcache->save( $p_result, $page, $popts );
                                        }
                                } else {
                                        $this->setWarning( $this->parseMsg( array( 'actionthrottledtext' ) ) );