Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / api / ApiPurge.php
index 5d1352c..324d030 100644 (file)
@@ -37,6 +37,11 @@ class ApiPurge extends ApiBase {
         * Purges the cache of a page
         */
        public function execute() {
+               $main = $this->getMain();
+               if ( !$main->isInternalMode() && !$main->getRequest()->wasPosted() ) {
+                       $this->addDeprecation( 'apiwarn-deprecation-purge-get', 'purge-via-GET' );
+               }
+
                $params = $this->extractRequestParams();
 
                $continuationManager = new ApiContinuationManager( $this, [], [] );
@@ -63,8 +68,7 @@ class ApiPurge extends ApiBase {
                                $page->doPurge( $flags );
                                $r['purged'] = true;
                        } else {
-                               $error = $this->parseMsg( [ 'actionthrottledtext' ] );
-                               $this->setWarning( $error['info'] );
+                               $this->addWarning( 'apierror-ratelimited' );
                        }
 
                        if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
@@ -108,8 +112,7 @@ class ApiPurge extends ApiBase {
                                                }
                                        }
                                } else {
-                                       $error = $this->parseMsg( [ 'actionthrottledtext' ] );
-                                       $this->setWarning( $error['info'] );
+                                       $this->addWarning( 'apierror-ratelimited' );
                                        $forceLinkUpdate = false;
                                }
                        }
@@ -158,6 +161,18 @@ class ApiPurge extends ApiBase {
                return !$this->getUser()->isAllowed( 'purge' );
        }
 
+       protected function getHelpFlags() {
+               $flags = parent::getHelpFlags();
+
+               // Claim that we must be posted for the purposes of help and paraminfo.
+               // @todo Remove this when self::mustBePosted() is updated for T145649
+               if ( !in_array( 'mustbeposted', $flags, true ) ) {
+                       $flags[] = 'mustbeposted';
+               }
+
+               return $flags;
+       }
+
        public function getAllowedParams( $flags = 0 ) {
                $result = [
                        'forcelinkupdate' => false,