fix merge of Iec98e472
[lhc/web/wiklou.git] / includes / api / ApiPurge.php
index c43c032..3cf32ad 100644 (file)
@@ -86,15 +86,18 @@ class ApiPurge extends ApiBase {
 
                        if( $forceLinkUpdate ) {
                                if ( !$user->pingLimiter() ) {
-                                       global $wgParser, $wgEnableParserCache;
+                                       global $wgEnableParserCache;
 
-                                       $popts = ParserOptions::newFromContext( $this->getContext() );
-                                       $p_result = $wgParser->parse( $page->getRawText(), $title, $popts,
-                                               true, true, $page->getLatest() ); #FIXME: content!
+                                       $popts = $page->makeParserOptions( 'canonical' );
+                                       $popts->setTidy( true );
+
+                                       # Parse content; note that HTML generation is only needed if we want to cache the result.
+                                       $content = $page->getContent( Revision::RAW );
+                                       $p_result = $content->getParserOutput( $title, $page->getLatest(), $popts, $wgEnableParserCache );
 
                                        # Update the links tables
-                                       $u = new LinksUpdate( $title, $p_result );
-                                       $u->doUpdate();
+                                       $updates = $content->getSecondaryDataUpdates( $title, null, true, $p_result );
+                                       DataUpdate::runUpdates( $updates );
 
                                        $r['linkupdate'] = '';
 
@@ -103,7 +106,8 @@ class ApiPurge extends ApiBase {
                                                $pcache->save( $p_result, $page, $popts );
                                        }
                                } else {
-                                       $this->setWarning( $this->parseMsg( array( 'actionthrottledtext' ) ) );
+                                       $error = $this->parseMsg( array( 'actionthrottledtext' ) );
+                                       $this->setWarning( $error['info'] );
                                        $forceLinkUpdate = false;
                                }
                        }
@@ -133,6 +137,34 @@ class ApiPurge extends ApiBase {
                );
        }
 
+       public function getResultProperties() {
+               return array(
+                       ApiBase::PROP_LIST => true,
+                       '' => array(
+                               'ns' => array(
+                                       ApiBase::PROP_TYPE => 'namespace',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'title' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'pageid' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'revid' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'invalid' => 'boolean',
+                               'missing' => 'boolean',
+                               'purged' => 'boolean',
+                               'linkupdate' => 'boolean'
+                       )
+               );
+       }
+
        public function getDescription() {
                return array( 'Purge the cache for the given titles.',
                        'Requires a POST request if the user is not logged in.'
@@ -143,7 +175,6 @@ class ApiPurge extends ApiBase {
                $psModule = new ApiPageSet( $this );
                return array_merge(
                        parent::getPossibleErrors(),
-                       array( array( 'cantpurge' ), ),
                        $psModule->getPossibleErrors()
                );
        }