*/
public $counter = -1;
+ /**
+ * @var array List of tags to apply
+ */
+ private $tags = [];
+
/**
* @var array Array of change types
*/
}
# If our database is strict about IP addresses, use NULL instead of an empty string
- if ( $dbw->strictIPs() && $this->mAttribs['rc_ip'] == '' ) {
+ $strictIPs = in_array( $dbw->getType(), [ 'oracle', 'postgres' ] ); // legacy
+ if ( $strictIPs && $this->mAttribs['rc_ip'] == '' ) {
unset( $this->mAttribs['rc_ip'] );
}
$this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
# # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
- if ( $dbw->cascadingDeletes() && $this->mAttribs['rc_cur_id'] == 0 ) {
+ if ( $this->mAttribs['rc_cur_id'] == 0 ) {
unset( $this->mAttribs['rc_cur_id'] );
}
# Notify extensions
Hooks::run( 'RecentChange_save', [ &$this ] );
+ if ( count( $this->tags ) ) {
+ ChangeTags::addTags( $this->tags, $this->mAttribs['rc_id'],
+ $this->mAttribs['rc_this_oldid'], $this->mAttribs['rc_logid'], null, $this );
+ }
+
# Notify external application via UDP
if ( !$noudp ) {
$this->notifyRCFeeds();
) {
// @FIXME: This would be better as an extension hook
// Send emails or email jobs once this row is safely committed
- $dbw->onTransactionIdle( function () use ( $editor, $title ) {
- $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']
- );
- } );
+ $dbw->onTransactionIdle(
+ function () use ( $editor, $title ) {
+ $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']
+ );
+ },
+ __METHOD__
+ );
}
}
DeferredUpdates::addCallableUpdate(
function () use ( $rc, $tags ) {
+ $rc->addTags( $tags );
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
- if ( count( $tags ) ) {
- ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
- $rc->mAttribs['rc_this_oldid'], null, null );
- }
},
DeferredUpdates::POSTSEND,
wfGetDB( DB_MASTER )
DeferredUpdates::addCallableUpdate(
function () use ( $rc, $tags ) {
+ $rc->addTags( $tags );
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
- if ( count( $tags ) ) {
- ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
- $rc->mAttribs['rc_this_oldid'], null, null );
- }
},
DeferredUpdates::POSTSEND,
wfGetDB( DB_MASTER )
return $unserializedParams;
}
+
+ /**
+ * Tags to append to the recent change,
+ * and associated revision/log
+ *
+ * @since 1.28
+ *
+ * @param string|array $tags
+ */
+ public function addTags( $tags ) {
+ if ( is_string( $tags ) ) {
+ $this->tags[] = $tags;
+ } else {
+ $this->tags = array_merge( $tags, $this->tags );
+ }
+ }
}