From: Brad Jorsch Date: Wed, 14 Sep 2016 15:04:33 +0000 (-0400) Subject: API: Deprecate use of ApiPurge via GET X-Git-Tag: 1.31.0-rc.0~5585^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=8e461ca44e3ccd2674eb1f96024fe27d432d4e69;p=lhc%2Fweb%2Fwiklou.git API: Deprecate use of ApiPurge via GET This emits a warning and logs feature usage, and also pretends that POST is required in the help and paraminfo output. Bug: T145649 Change-Id: Ied8d47a947662158fddab383c764bf70c5ab0112 --- diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 5d1352ce3f..8bbd88dfec 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -37,6 +37,12 @@ class ApiPurge extends ApiBase { * Purges the cache of a page */ public function execute() { + $main = $this->getMain(); + if ( !$main->isInternalMode() && !$main->getRequest()->wasPosted() ) { + $this->logFeatureUsage( 'purge-via-GET' ); + $this->setWarning( 'Use of action=purge via GET is deprecated. Use POST instead.' ); + } + $params = $this->extractRequestParams(); $continuationManager = new ApiContinuationManager( $this, [], [] ); @@ -158,6 +164,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,