From 222b01f5169f1c7e69762e0e8904c24f78f71882 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 28 Jul 2010 11:52:48 +0200 Subject: update to MediaWiki 1.16.0 --- includes/api/ApiPurge.php | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'includes/api/ApiPurge.php') diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index d1e6824d..76d45404 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -23,8 +23,8 @@ * http://www.gnu.org/copyleft/gpl.html */ -if (!defined('MEDIAWIKI')) { - require_once ('ApiBase.php'); +if ( !defined( 'MEDIAWIKI' ) ) { + require_once ( 'ApiBase.php' ); } /** @@ -33,8 +33,8 @@ if (!defined('MEDIAWIKI')) { */ class ApiPurge extends ApiBase { - public function __construct($main, $action) { - parent :: __construct($main, $action); + public function __construct( $main, $action ) { + parent :: __construct( $main, $action ); } /** @@ -43,35 +43,35 @@ 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->dieUsageMsg( array( 'cantpurge' ) ); + if ( !isset( $params['titles'] ) ) + $this->dieUsageMsg( array( 'missingparam', 'titles' ) ); $result = array(); - foreach($params['titles'] as $t) { + foreach ( $params['titles'] as $t ) { $r = array(); - $title = Title::newFromText($t); - if(!$title instanceof Title) + $title = Title::newFromText( $t ); + if ( !$title instanceof Title ) { $r['title'] = $t; $r['invalid'] = ''; $result[] = $r; continue; } - ApiQueryBase::addTitleInfo($r, $title); - if(!$title->exists()) + ApiQueryBase::addTitleInfo( $r, $title ); + if ( !$title->exists() ) { $r['missing'] = ''; $result[] = $r; continue; } - $article = new Article($title); + $article = Mediawiki::articleFromTitle( $title ); $article->doPurge(); // Directly purge and skip the UI part of purge(). $r['purged'] = ''; $result[] = $r; } - $this->getResult()->setIndexedTagName($result, 'page'); - $this->getResult()->addValue(null, $this->getModuleName(), $result); + $this->getResult()->setIndexedTagName( $result, 'page' ); + $this->getResult()->addValue( null, $this->getModuleName(), $result ); } public function mustBePosted() { @@ -102,6 +102,13 @@ class ApiPurge extends ApiBase { 'Purge the cache for the given titles.' ); } + + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'cantpurge' ), + array( 'missingparam', 'titles' ), + ) ); + } protected function getExamples() { return array( @@ -110,6 +117,6 @@ class ApiPurge extends ApiBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiPurge.php 69579 2010-07-20 02:49:55Z tstarling $'; + return __CLASS__ . ': $Id: ApiPurge.php 69578 2010-07-20 02:46:20Z tstarling $'; } } -- cgit v1.2.3-54-g00ecf