Quick fix for bug 15892: intermittent SQL-based cache failures during parser test...
[mediawiki.git] / includes / api / ApiPatrol.php
blob04afd1dc585809d9cad0216168a96f096d7771a1
1 <?php
2 /**
3 * API for MediaWiki 1.14+
5 * Created on Sep 2, 2008
7 * Copyright © 2008 Soxred93 soxred93@gmail.com,
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
24 * @file
27 if ( !defined( 'MEDIAWIKI' ) ) {
28 require_once ( 'ApiBase.php' );
31 /**
32 * Allows user to patrol pages
33 * @ingroup API
35 class ApiPatrol extends ApiBase {
37 public function __construct( $main, $action ) {
38 parent::__construct( $main, $action );
41 /**
42 * Patrols the article or provides the reason the patrol failed.
44 public function execute() {
45 $params = $this->extractRequestParams();
47 $rc = RecentChange::newFromID( $params['rcid'] );
48 if ( !$rc instanceof RecentChange ) {
49 $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
51 $retval = RecentChange::markPatrolled( $params['rcid'] );
53 if ( $retval ) {
54 $this->dieUsageMsg( reset( $retval ) );
57 $result = array( 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) );
58 ApiQueryBase::addTitleInfo( $result, $rc->getTitle() );
59 $this->getResult()->addValue( null, $this->getModuleName(), $result );
62 public function mustBePosted() {
63 return true;
66 public function isWriteMode() {
67 return true;
70 public function getAllowedParams() {
71 return array(
72 'token' => null,
73 'rcid' => array(
74 ApiBase::PARAM_TYPE => 'integer',
75 ApiBase::PARAM_REQUIRED => true
80 public function getParamDescription() {
81 return array(
82 'token' => 'Patrol token obtained from list=recentchanges',
83 'rcid' => 'Recentchanges ID to patrol',
87 public function getDescription() {
88 return 'Patrol a page or revision';
91 public function getPossibleErrors() {
92 return array_merge( parent::getPossibleErrors(), array(
93 array( 'nosuchrcid', 'rcid' ),
94 ) );
97 public function needsToken() {
98 return true;
101 public function getTokenSalt() {
102 return 'patrol';
105 protected function getExamples() {
106 return array(
107 'api.php?action=patrol&token=123abc&rcid=230672766'
111 public function getVersion() {
112 return __CLASS__ . ': $Id$';