const SRC_NEW = 'mw.new';
const SRC_LOG = 'mw.log';
const SRC_EXTERNAL = 'mw.external'; // obsolete
+ const SRC_CATEGORIZE = 'mw.categorize';
public $mAttribs = array();
public $mExtra = array();
'new' => RC_NEW,
'log' => RC_LOG,
'external' => RC_EXTERNAL,
+ 'categorize' => RC_CATEGORIZE,
);
# Factory methods
*
* @param array $conds Array of conditions
* @param mixed $fname Override the method name in profiling/logs
- * @param array $options Query options
+ * @param int $dbType DB_* constant
+ *
* @return RecentChange|null
*/
- public static function newFromConds( $conds, $fname = __METHOD__, $options = array() ) {
- $dbr = wfGetDB( DB_SLAVE );
- $row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname, $options );
+ public static function newFromConds(
+ $conds,
+ $fname = __METHOD__,
+ $dbType = DB_SLAVE
+ ) {
+ $db = wfGetDB( $dbType );
+ $row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
if ( $row !== false ) {
return self::newFromRow( $row );
} else {
$editor = $this->getPerformer();
$title = $this->getTitle();
- if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
- # @todo FIXME: This would be better as an extension hook
- $enotif = new EmailNotification();
- $enotif->notifyOnPageChange( $editor, $title,
- $this->mAttribs['rc_timestamp'],
- $this->mAttribs['rc_comment'],
- $this->mAttribs['rc_minor'],
- $this->mAttribs['rc_last_oldid'],
- $this->mExtra['pageStatus'] );
+ // Never send an RC notification email about categorization changes
+ if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) {
+ if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
+ # @todo FIXME: This would be better as an extension hook
+ $enotif = new EmailNotification();
+ $enotif->notifyOnPageChange(
+ $editor,
+ $title,
+ $this->mAttribs['rc_timestamp'],
+ $this->mAttribs['rc_comment'],
+ $this->mAttribs['rc_minor'],
+ $this->mAttribs['rc_last_oldid'],
+ $this->mExtra['pageStatus']
+ );
+ }
}
}
* @return array Array of permissions errors, see Title::getUserPermissionsErrors()
*/
public function doMarkPatrolled( User $user, $auto = false ) {
- global $wgUseRCPatrol, $wgUseNPPatrol;
+ global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
$errors = array();
- // If recentchanges patrol is disabled, only new pages
- // can be patrolled
- if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) ) {
+ // If recentchanges patrol is disabled, only new pages or new file versions
+ // can be patrolled, provided the appropriate config variable is set
+ if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
+ ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
+ $this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
$errors[] = array( 'rcpatroldisabled' );
}
// Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
$right = $auto ? 'autopatrol' : 'patrol';
$errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
- if ( !Hooks::run( 'MarkPatrolled', array( $this->getAttribute( 'rc_id' ), &$user, false ) ) ) {
+ if ( !Hooks::run( 'MarkPatrolled',
+ array( $this->getAttribute( 'rc_id' ), &$user, false, $auto ) )
+ ) {
$errors[] = array( 'hookaborted' );
}
// Users without the 'autopatrol' right can't patrol their
$this->reallyMarkPatrolled();
// Log this patrol event
PatrolLog::record( $this, $auto, $user );
- Hooks::run( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) );
+ Hooks::run(
+ 'MarkPatrolledComplete',
+ array( $this->getAttribute( 'rc_id' ), &$user, false, $auto )
+ );
return array();
}
* @param string $params
* @param int $newId
* @param string $actionCommentIRC
+ * @param int $revId Id of associated revision, if any
* @return RecentChange
*/
public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
- $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' ) {
+ $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
+ $revId = 0 ) {
global $wgRequest;
# # Get pageStatus for email notification
break;
}
+ // Allow unpatrolled status when an associated rev id is passed
+ // May be used in core by moves and uploads
+ $markPatrolled = ( $revId > 0 ) ? $user->isAllowed( 'autopatrol' ) : true;
+
$rc = new RecentChange;
$rc->mTitle = $target;
$rc->mPerformer = $user;
'rc_user' => $user->getId(),
'rc_user_text' => $user->getName(),
'rc_comment' => $logComment,
- 'rc_this_oldid' => 0,
+ 'rc_this_oldid' => $revId,
'rc_last_oldid' => 0,
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
'rc_ip' => self::checkIPAddress( $ip ),
- 'rc_patrolled' => 1,
+ 'rc_patrolled' => $markPatrolled ? 1 : 0,
'rc_new' => 0, # obsolete
'rc_old_len' => null,
'rc_new_len' => null,
return $rc;
}
+ /**
+ * Constructs a RecentChange object for the given categorization
+ * This does not call save() on the object and thus does not write to the db
+ *
+ * @since 1.27
+ *
+ * @param string $timestamp Timestamp of the recent change to occur
+ * @param Title $categoryTitle Title of the category a page is being added to or removed from
+ * @param User $user User object of the user that made the change
+ * @param string $comment Change summary
+ * @param Title $pageTitle Title of the page that is being added or removed
+ * @param int $oldRevId Parent revision ID of this change
+ * @param int $newRevId Revision ID of this change
+ * @param string $lastTimestamp Parent revision timestamp of this change
+ * @param bool $bot true, if the change was made by a bot
+ * @param string $ip IP address of the user, if the change was made anonymously
+ * @param int $deleted Indicates whether the change has been deleted
+ *
+ * @return RecentChange
+ */
+ public static function newForCategorization(
+ $timestamp,
+ Title $categoryTitle,
+ User $user = null,
+ $comment,
+ Title $pageTitle,
+ $oldRevId,
+ $newRevId,
+ $lastTimestamp,
+ $bot,
+ $ip = '',
+ $deleted = 0
+ ) {
+ $rc = new RecentChange;
+ $rc->mTitle = $categoryTitle;
+ $rc->mPerformer = $user;
+ $rc->mAttribs = array(
+ 'rc_timestamp' => $timestamp,
+ 'rc_namespace' => $categoryTitle->getNamespace(),
+ 'rc_title' => $categoryTitle->getDBkey(),
+ 'rc_type' => RC_CATEGORIZE,
+ 'rc_source' => self::SRC_CATEGORIZE,
+ 'rc_minor' => 0,
+ 'rc_cur_id' => $pageTitle->getArticleID(),
+ 'rc_user' => $user ? $user->getId() : 0,
+ 'rc_user_text' => $user ? $user->getName() : '',
+ 'rc_comment' => $comment,
+ 'rc_this_oldid' => $newRevId,
+ 'rc_last_oldid' => $oldRevId,
+ 'rc_bot' => $bot ? 1 : 0,
+ 'rc_ip' => self::checkIPAddress( $ip ),
+ 'rc_patrolled' => 1, // Always patrolled, just like log entries
+ 'rc_new' => 0, # obsolete
+ 'rc_old_len' => 0,
+ 'rc_new_len' => 0,
+ 'rc_deleted' => $deleted,
+ 'rc_logid' => 0,
+ 'rc_log_type' => null,
+ 'rc_log_action' => '',
+ 'rc_params' => ''
+ );
+
+ $rc->mExtra = array(
+ 'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(),
+ 'lastTimestamp' => $lastTimestamp,
+ 'oldSize' => 0,
+ 'newSize' => 0,
+ 'pageStatus' => 'changed'
+ );
+
+ return $rc;
+ }
+
/**
* Initialises the members of this object from a mysql row object
*
return $unserializedParams;
}
}
+