Index: includes/api/ApiBase.php =================================================================== --- includes/api/ApiBase.php (revision 40411) +++ includes/api/ApiBase.php (working copy) @@ -675,6 +675,7 @@ 'permdenied-undelete' => array('code' => 'permissiondenied', 'info' => "You don't have permission to restore deleted revisions"), 'createonly-exists' => array('code' => 'articleexists', 'info' => "The article you tried to create has been created already"), 'nocreate-missing' => array('code' => 'missingtitle', 'info' => "The article you tried to edit doesn't exist"), + 'cantpurge' => array('code' => 'cantpurge', 'info' => "Only users with the 'purge' right can purge pages via the API"), // ApiEditPage messages 'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"), Index: includes/api/ApiMain.php =================================================================== --- includes/api/ApiMain.php (revision 40411) +++ includes/api/ApiMain.php (working copy) @@ -65,6 +65,7 @@ 'feedwatchlist' => 'ApiFeedWatchlist', 'help' => 'ApiHelp', 'paraminfo' => 'ApiParamInfo', + 'purge' => 'ApiPurge', ); private static $WriteModules = array ( Index: includes/api/ApiPurge.php =================================================================== --- includes/api/ApiPurge.php (revision 0) +++ includes/api/ApiPurge.php (revision 0) @@ -0,0 +1,84 @@ + +extractRequestParams(); + if( !$wgUser->isAllowed('purge') ) + $this->dieUsageMsg(array('cantpurge')); + if( !isset( $params['titles'] ) ) { + $this->dieUsageMsg(array('missingparam', 'titles') ); + } + $titleList = explode( '|', $params['titles'] ); + $array = array(); + foreach ( $titleList as $title ) { + $article = MediaWiki :: articleFromTitle( Title::newFromText( $title ) ); + $article->doPurge(); // Directly purge and skip the UI part of purge(). + } + } + + public function getAllowedParams() { + return array ( + 'titles' => null, + ); + } + + public function getParamDescription() { + return array ( + 'titles' => 'A list of titles, separated by |', + ); + } + + public function getDescription() { + return array ( + 'Purge the cache for the given titles.' + ); + } + + protected function getExamples() { + return array( + 'api.php?action=purge&titles=Main_Page|API' + ); + } + + public function getVersion() { + return __CLASS__ . ': $Id: ApiPurge.php 40346 2008-09-02 23:40:56Z soxred93 $'; + } +} Property changes on: includes\api\ApiPurge.php ___________________________________________________________________ Name: svn:eol-style + native Index: includes/AutoLoader.php =================================================================== --- includes/AutoLoader.php (revision 40411) +++ includes/AutoLoader.php (working copy) @@ -239,6 +239,7 @@ 'ApiParamInfo' => 'includes/api/ApiParamInfo.php', 'ApiParse' => 'includes/api/ApiParse.php', 'ApiProtect' => 'includes/api/ApiProtect.php', + 'ApiPurge' => 'includes/api/ApiPurge.php', 'ApiQuery' => 'includes/api/ApiQuery.php', 'ApiQueryAllCategories' => 'includes/api/ApiQueryAllCategories.php', 'ApiQueryAllimages' => 'includes/api/ApiQueryAllimages.php', @@ -577,3 +578,4 @@ } } +