jenkins-bot has submitted this change and it was merged.
Change subject: Allow patrolling pages by revision id
......................................................................
Allow patrolling pages by revision id
This became necessary as it's quite hard to
get the rc id of a change from the html after
I1e24733c.
Bug: 49259
Change-Id: Ia7d3960cf11bf8ae0fc06ae1a0f7fcfb3c080f21
---
M RELEASE-NOTES-1.22
M includes/Revision.php
M includes/api/ApiPatrol.php
3 files changed, 57 insertions(+), 15 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 0b1d88a..4f33548 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -170,6 +170,7 @@
* New upload log entries will now contain information on the relavent
image (sha1 and timestamp).
* (bug 49239) action=parse now can parse in preview mode.
+* (bug 49259) action=patrol now accepts revision ids.
=== Languages updated in 1.22===
diff --git a/includes/Revision.php b/includes/Revision.php
index 47626a2..b3b971b 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -867,24 +867,37 @@
}
/**
- * @return Integer rcid of the unpatrolled row, zero if there isn't one
+ * @return integer rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
if ( $this->mUnpatrolled !== null ) {
return $this->mUnpatrolled;
}
+ $rc = $this->getRecentChange();
+ if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == 0 ) {
+ $this->mUnpatrolled = $rc->getAttribute( 'rc_id' );
+ } else {
+ $this->mUnpatrolled = 0;
+ }
+ return $this->mUnpatrolled;
+ }
+
+ /**
+ * Get the RC object belonging to the current revision, if there's one
+ *
+ * @since 1.22
+ * @return RecentChange|null
+ */
+ public function getRecentChange() {
$dbr = wfGetDB( DB_SLAVE );
- $this->mUnpatrolled = $dbr->selectField( 'recentchanges',
- 'rc_id',
- array( // Add redundant user,timestamp condition so we
can use the existing index
+ return RecentChange::newFromConds(
+ array(
'rc_user_text' => $this->getRawUserText(),
'rc_timestamp' => $dbr->timestamp(
$this->getTimestamp() ),
- 'rc_this_oldid' => $this->getId(),
- 'rc_patrolled' => 0
+ 'rc_this_oldid' => $this->getId()
),
__METHOD__
);
- return (int)$this->mUnpatrolled;
}
/**
diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php
index 4d4fbba..bd2fde2 100644
--- a/includes/api/ApiPatrol.php
+++ b/includes/api/ApiPatrol.php
@@ -35,11 +35,27 @@
*/
public function execute() {
$params = $this->extractRequestParams();
+ $this->requireOnlyOneParameter( $params, 'rcid', 'revid' );
- $rc = RecentChange::newFromID( $params['rcid'] );
- if ( !$rc instanceof RecentChange ) {
- $this->dieUsageMsg( array( 'nosuchrcid',
$params['rcid'] ) );
+ if ( isset( $params['rcid'] ) ) {
+ $rc = RecentChange::newFromID( $params['rcid'] );
+ if ( !$rc ) {
+ $this->dieUsageMsg( array( 'nosuchrcid',
$params['rcid'] ) );
+ }
+ } else {
+ $rev = Revision::newFromId( $params['revid'] );
+ if ( !$rev ) {
+ $this->dieUsageMsg( array( 'nosuchrevid',
$params['revid'] ) );
+ }
+ $rc = $rev->getRecentChange();
+ if ( !$rc ) {
+ $this->dieUsage(
+ 'The revision ' . $params['revid'] . "
can't be patrolled as it's too old",
+ 'notpatrollable'
+ );
+ }
}
+
$retval = $rc->doMarkPatrolled( $this->getUser() );
if ( $retval ) {
@@ -66,8 +82,10 @@
ApiBase::PARAM_REQUIRED => true
),
'rcid' => array(
- ApiBase::PARAM_TYPE => 'integer',
- ApiBase::PARAM_REQUIRED => true
+ ApiBase::PARAM_TYPE => 'integer'
+ ),
+ 'revid' => array(
+ ApiBase::PARAM_TYPE => 'integer'
),
);
}
@@ -76,6 +94,7 @@
return array(
'token' => 'Patrol token obtained from
list=recentchanges',
'rcid' => 'Recentchanges ID to patrol',
+ 'revid' => 'Revision ID to patrol',
);
}
@@ -94,8 +113,16 @@
}
public function getPossibleErrors() {
- return array_merge( parent::getPossibleErrors(), array(
- array( 'nosuchrcid', 'rcid' ),
+ return array_merge(
+ parent::getPossibleErrors(),
+ parent::getRequireOnlyOneParameterErrorMessages( array(
'rcid', 'revid' ) ),
+ array(
+ array( 'nosuchrcid', 'rcid' ),
+ array( 'nosuchrevid', 'revid' ),
+ array(
+ 'code' => 'notpatrollable',
+ 'info' => "The revision can't be
patrolled as it's too old"
+ )
) );
}
@@ -109,7 +136,8 @@
public function getExamples() {
return array(
- 'api.php?action=patrol&token=123abc&rcid=230672766'
+ 'api.php?action=patrol&token=123abc&rcid=230672766',
+ 'api.php?action=patrol&token=123abc&revid=230672766'
);
}
--
To view, visit https://gerrit.wikimedia.org/r/67624
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7d3960cf11bf8ae0fc06ae1a0f7fcfb3c080f21
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits