Merge "content: Recognise .json as JsonContent in User and MediaWiki namespace"
[lhc/web/wiklou.git] / includes / api / ApiPurge.php
index 7667b23..a22be49 100644 (file)
@@ -38,7 +38,8 @@ class ApiPurge extends ApiBase {
        public function execute() {
                $params = $this->extractRequestParams();
 
-               $this->getResult()->beginContinuation( $params['continue'], array(), array() );
+               $continuationManager = new ApiContinuationManager( $this, array(), array() );
+               $this->setContinuationManager( $continuationManager );
 
                $forceLinkUpdate = $params['forcelinkupdate'];
                $forceRecursiveLinkUpdate = $params['forcerecursivelinkupdate'];
@@ -52,7 +53,7 @@ class ApiPurge extends ApiBase {
                        ApiQueryBase::addTitleInfo( $r, $title );
                        $page = WikiPage::factory( $title );
                        $page->doPurge(); // Directly purge and skip the UI part of purge().
-                       $r['purged'] = '';
+                       $r['purged'] = true;
 
                        if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
                                if ( !$this->getUser()->pingLimiter( 'linkpurge' ) ) {
@@ -73,7 +74,7 @@ class ApiPurge extends ApiBase {
                                                $title, null, $forceRecursiveLinkUpdate, $p_result );
                                        DataUpdate::runUpdates( $updates );
 
-                                       $r['linkupdate'] = '';
+                                       $r['linkupdate'] = true;
 
                                        if ( $enableParserCache ) {
                                                $pcache = ParserCache::singleton();
@@ -89,7 +90,7 @@ class ApiPurge extends ApiBase {
                        $result[] = $r;
                }
                $apiResult = $this->getResult();
-               $apiResult->setIndexedTagName( $result, 'page' );
+               ApiResult::setIndexedTagName( $result, 'page' );
                $apiResult->addValue( null, $this->getModuleName(), $result );
 
                $values = $pageSet->getNormalizedTitlesAsResult( $apiResult );
@@ -105,7 +106,8 @@ class ApiPurge extends ApiBase {
                        $apiResult->addValue( null, 'redirects', $values );
                }
 
-               $apiResult->endContinuation();
+               $this->setContinuationManager( null );
+               $continuationManager->setContinuationIntoResult( $apiResult );
        }
 
        /**
@@ -133,7 +135,9 @@ class ApiPurge extends ApiBase {
                $result = array(
                        'forcelinkupdate' => false,
                        'forcerecursivelinkupdate' => false,
-                       'continue' => '',
+                       'continue' => array(
+                               ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
+                       ),
                );
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
@@ -142,25 +146,12 @@ class ApiPurge extends ApiBase {
                return $result;
        }
 
-       public function getParamDescription() {
-               return $this->getPageSet()->getFinalParamDescription()
-                       + array(
-                               'forcelinkupdate' => 'Update the links tables',
-                               'forcerecursivelinkupdate' => 'Update the links table, and update ' .
-                                       'the links tables for any page that uses this page as a template',
-                               'continue' => 'When more results are available, use this to continue',
-                       );
-       }
-
-       public function getDescription() {
-               return array( 'Purge the cache for the given titles.',
-                       'Requires a POST request if the user is not logged in.'
-               );
-       }
-
-       public function getExamples() {
+       protected function getExamplesMessages() {
                return array(
-                       'api.php?action=purge&titles=Main_Page|API' => 'Purge the "Main Page" and the "API" page',
+                       'action=purge&titles=Main_Page|API'
+                               => 'apihelp-purge-example-simple',
+                       'action=purge&generator=allpages&gapnamespace=0&gaplimit=10'
+                               => 'apihelp-purge-example-generator',
                );
        }