JavaScriptMinifier: Fix "Uninitialized offset" in string and regexp parsing
[lhc/web/wiklou.git] / includes / api / ApiPurge.php
index 324d030..b7cfc2c 100644 (file)
@@ -1,12 +1,6 @@
 <?php
 
 /**
- * API for MediaWiki 1.14+
- *
- * Created on Sep 2, 2008
- *
- * Copyright © 2008 Chad Horohoe
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -25,6 +19,7 @@
  * @file
  */
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * API interface for page purging
@@ -37,11 +32,6 @@ 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, [], [] );
@@ -60,12 +50,8 @@ class ApiPurge extends ApiBase {
                        ApiQueryBase::addTitleInfo( $r, $title );
                        $page = WikiPage::factory( $title );
                        if ( !$user->pingLimiter( 'purge' ) ) {
-                               $flags = WikiPage::PURGE_ALL;
-                               if ( !$this->getRequest()->wasPosted() ) {
-                                       $flags ^= WikiPage::PURGE_GLOBAL_PCACHE; // skip DB_MASTER write
-                               }
                                // Directly purge and skip the UI part of purge()
-                               $page->doPurge( $flags );
+                               $page->doPurge();
                                $r['purged'] = true;
                        } else {
                                $this->addWarning( 'apierror-ratelimited' );
@@ -101,13 +87,14 @@ class ApiPurge extends ApiBase {
                                                $updates = $content->getSecondaryDataUpdates(
                                                        $title, null, $forceRecursiveLinkUpdate, $p_result );
                                                foreach ( $updates as $update ) {
+                                                       $update->setCause( 'api-purge', $this->getUser()->getName() );
                                                        DeferredUpdates::addUpdate( $update, DeferredUpdates::PRESEND );
                                                }
 
                                                $r['linkupdate'] = true;
 
                                                if ( $enableParserCache ) {
-                                                       $pcache = ParserCache::singleton();
+                                                       $pcache = MediaWikiServices::getInstance()->getParserCache();
                                                        $pcache->save( $p_result, $page, $popts );
                                                }
                                        }
@@ -157,20 +144,7 @@ class ApiPurge extends ApiBase {
        }
 
        public function mustBePosted() {
-               // Anonymous users are not allowed a non-POST request
-               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;
+               return true;
        }
 
        public function getAllowedParams( $flags = 0 ) {
@@ -198,6 +172,6 @@ class ApiPurge extends ApiBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Purge';
+               return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Purge';
        }
 }