diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/api/ApiPurge.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/api/ApiPurge.php')
-rw-r--r-- | includes/api/ApiPurge.php | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 76d45404..a17abf16 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -1,11 +1,11 @@ <?php -/* - * Created on Sep 2, 2008 - * +/** * API for MediaWiki 1.14+ * - * Copyright (C) 2008 Chad Horohoe + * 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 @@ -19,12 +19,14 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html + * + * @file */ if ( !defined( 'MEDIAWIKI' ) ) { - require_once ( 'ApiBase.php' ); + require_once( 'ApiBase.php' ); } /** @@ -34,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { class ApiPurge extends ApiBase { public function __construct( $main, $action ) { - parent :: __construct( $main, $action ); + parent::__construct( $main, $action ); } /** @@ -43,29 +45,27 @@ class ApiPurge extends ApiBase { public function execute() { global $wgUser; $params = $this->extractRequestParams(); - if ( !$wgUser->isAllowed( 'purge' ) ) - $this->dieUsageMsg( array( 'cantpurge' ) ); - if ( !isset( $params['titles'] ) ) - $this->dieUsageMsg( array( 'missingparam', 'titles' ) ); + if ( !$wgUser->isAllowed( 'purge' ) && !$this->getMain()->isInternalMode() && + !$this->getMain()->getRequest()->wasPosted() ) { + $this->dieUsageMsg( array( 'mustbeposted', $this->getModuleName() ) ); + } $result = array(); foreach ( $params['titles'] as $t ) { $r = array(); $title = Title::newFromText( $t ); - if ( !$title instanceof Title ) - { + if ( !$title instanceof Title ) { $r['title'] = $t; $r['invalid'] = ''; $result[] = $r; continue; } ApiQueryBase::addTitleInfo( $r, $title ); - if ( !$title->exists() ) - { + if ( !$title->exists() ) { $r['missing'] = ''; $result[] = $r; continue; } - $article = Mediawiki::articleFromTitle( $title ); + $article = MediaWiki::articleFromTitle( $title ); $article->doPurge(); // Directly purge and skip the UI part of purge(). $r['purged'] = ''; $result[] = $r; @@ -74,40 +74,35 @@ class ApiPurge extends ApiBase { $this->getResult()->addValue( null, $this->getModuleName(), $result ); } - public function mustBePosted() { - global $wgUser; - return $wgUser->isAnon(); - } - public function isWriteMode() { return true; } public function getAllowedParams() { - return array ( + return array( 'titles' => array( - ApiBase :: PARAM_ISMULTI => true + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_REQUIRED => true ) ); } public function getParamDescription() { - return array ( + return array( 'titles' => 'A list of titles', ); } public function getDescription() { - return array ( - 'Purge the cache for the given titles.' + return array( 'Purge the cache for the given titles.', + 'This module requires a POST request if the user is not logged in.' ); } - - public function getPossibleErrors() { + + public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'cantpurge' ), - array( 'missingparam', 'titles' ), - ) ); + ) ); } protected function getExamples() { @@ -117,6 +112,6 @@ class ApiPurge extends ApiBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiPurge.php 69578 2010-07-20 02:46:20Z tstarling $'; + return __CLASS__ . ': $Id: ApiPurge.php 74944 2010-10-18 09:19:20Z catrope $'; } } |