35 parent::__construct( $main, $action );
37 $this->revisionStore = $revisionStore;
38 $this->patrolManager = $patrolManager;
39 $this->recentChangeLookup = $recentChangeLookup;
49 if ( isset( $params[
'rcid'] ) ) {
50 $rc = $this->recentChangeLookup->getRecentChangeById( $params[
'rcid'] );
52 $this->
dieWithError( [
'apierror-nosuchrcid', $params[
'rcid'] ] );
55 $rev = $this->revisionStore->getRevisionById( $params[
'revid'] );
57 $this->
dieWithError( [
'apierror-nosuchrevid', $params[
'revid'] ] );
59 $rc = $this->revisionStore->getRecentChange( $rev );
61 $this->
dieWithError( [
'apierror-notpatrollable', $params[
'revid'] ] );
66 $tags = $params[
'tags'];
69 if ( $tags !==
null ) {
70 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $tags, $this->
getAuthority() );
71 if ( !$ableToTag->isOK() ) {
76 $status = $this->patrolManager->markPatrolled( $rc, $user, $tags );
78 if ( !$status->isGood() ) {
82 $result = [
'rcid' => (int)$rc->getAttribute(
'rc_id' ) ];
101 ParamValidator::PARAM_TYPE =>
'integer'
104 ParamValidator::PARAM_TYPE =>
'integer'
107 ParamValidator::PARAM_TYPE =>
'tags',
108 ParamValidator::PARAM_ISMULTI =>
true,
121 'action=patrol&token=123ABC&rcid=230672766'
122 =>
'apihelp-patrol-example-rcid',
123 'action=patrol&token=123ABC&revid=230672766'
124 =>
'apihelp-patrol-example-revid',
130 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Patrol';
135class_alias( ApiPatrol::class,
'ApiPatrol' );
This is the main API class, used for both external and internal processing.