summaryrefslogtreecommitdiff
path: root/includes/api/ApiPurge.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiPurge.php')
-rw-r--r--includes/api/ApiPurge.php41
1 files changed, 24 insertions, 17 deletions
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 $';
}
}