* @file
*/
+use MediaWiki\Storage\RevisionRecord;
+
/**
* A query action to enumerate the recent changes that were done to the wiki.
* Various filters are supported.
/**
* Generates and outputs the result of this query based upon the provided parameters.
*
- * @param ApiPageSet $resultPageSet
+ * @param ApiPageSet|null $resultPageSet
*/
public function run( $resultPageSet = null ) {
$user = $this->getUser();
}
}
+ $title = $params['title'];
+ if ( !is_null( $title ) ) {
+ $titleObj = Title::newFromText( $title );
+ if ( is_null( $titleObj ) ) {
+ $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
+ }
+ $this->addWhereFld( 'rc_namespace', $titleObj->getNamespace() );
+ $this->addWhereFld( 'rc_title', $titleObj->getDBkey() );
+ }
+
if ( !is_null( $params['show'] ) ) {
$show = array_flip( $params['show'] );
if ( isset( $show['unpatrolled'] ) ) {
// See ChangesList::isUnpatrolled
if ( $user->useRCPatrol() ) {
- $this->addWhere( 'rc_patrolled = 0' );
+ $this->addWhere( 'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED );
} elseif ( $user->useNPPatrol() ) {
- $this->addWhere( 'rc_patrolled = 0' );
+ $this->addWhere( 'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED );
$this->addWhereFld( 'rc_type', RC_NEW );
}
}
- $this->addWhereIf( 'rc_patrolled != 2', isset( $show['!autopatrolled'] ) );
- $this->addWhereIf( 'rc_patrolled = 2', isset( $show['autopatrolled'] ) );
+ $this->addWhereIf(
+ 'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED,
+ isset( $show['!autopatrolled'] )
+ );
+ $this->addWhereIf(
+ 'rc_patrolled = ' . RecentChange::PRC_AUTOPATROLLED,
+ isset( $show['autopatrolled'] )
+ );
// Don't throw log entries out the window here
$this->addWhereIf(
// Paranoia: avoid brute force searches (T19342)
if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
if ( !$user->isAllowed( 'deletedhistory' ) ) {
- $bitmask = Revision::DELETED_USER;
+ $bitmask = RevisionRecord::DELETED_USER;
} elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
- $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
+ $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
/* Add user data and 'anon' flag, if user is anonymous. */
if ( $this->fld_user || $this->fld_userid ) {
- if ( $row->rc_deleted & Revision::DELETED_USER ) {
+ if ( $row->rc_deleted & RevisionRecord::DELETED_USER ) {
$vals['userhidden'] = true;
$anyHidden = true;
}
- if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_USER, $user ) ) {
+ if ( RevisionRecord::userCanBitfield( $row->rc_deleted, RevisionRecord::DELETED_USER, $user ) ) {
if ( $this->fld_user ) {
$vals['user'] = $row->rc_user_text;
}
/* Add edit summary / log summary. */
if ( $this->fld_comment || $this->fld_parsedcomment ) {
- if ( $row->rc_deleted & Revision::DELETED_COMMENT ) {
+ if ( $row->rc_deleted & RevisionRecord::DELETED_COMMENT ) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
- if ( Revision::userCanBitfield( $row->rc_deleted, Revision::DELETED_COMMENT, $user ) ) {
+ if ( RevisionRecord::userCanBitfield(
+ $row->rc_deleted, RevisionRecord::DELETED_COMMENT, $user
+ ) ) {
$comment = $this->commentStore->getComment( 'rc_comment', $row )->text;
if ( $this->fld_comment ) {
$vals['comment'] = $comment;
/* Add the patrolled flag */
if ( $this->fld_patrolled ) {
- $vals['patrolled'] = $row->rc_patrolled != 0;
+ $vals['patrolled'] = $row->rc_patrolled != RecentChange::PRC_UNPATROLLED;
$vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
- $vals['autopatrolled'] = $row->rc_patrolled == 2;
+ $vals['autopatrolled'] = $row->rc_patrolled == RecentChange::PRC_AUTOPATROLLED;
}
if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
}
if ( $this->fld_sha1 && $row->rev_sha1 !== null ) {
- if ( $row->rev_deleted & Revision::DELETED_TEXT ) {
+ if ( $row->rev_deleted & RevisionRecord::DELETED_TEXT ) {
$vals['sha1hidden'] = true;
$anyHidden = true;
}
- if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_TEXT, $user ) ) {
+ if ( RevisionRecord::userCanBitfield(
+ $row->rev_deleted, RevisionRecord::DELETED_TEXT, $user
+ ) ) {
if ( $row->rev_sha1 !== '' ) {
$vals['sha1'] = Wikimedia\base_convert( $row->rev_sha1, 36, 16, 40 );
} else {
}
}
- if ( $anyHidden && ( $row->rc_deleted & Revision::DELETED_RESTRICTED ) ) {
+ if ( $anyHidden && ( $row->rc_deleted & RevisionRecord::DELETED_RESTRICTED ) ) {
$vals['suppressed'] = true;
}
ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
],
'toponly' => false,
+ 'title' => null,
'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
],