public static function newFromConds(
$conds,
$fname = __METHOD__,
- $dbType = DB_SLAVE
+ $dbType = DB_REPLICA
) {
$db = wfGetDB( $dbType );
$row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
$this->mAttribs['rc_ip'] = '';
}
+ # Strict mode fixups (not-NULL fields)
+ foreach ( [ 'minor', 'bot', 'new', 'patrolled', 'deleted' ] as $field ) {
+ $this->mAttribs["rc_$field"] = (int)$this->mAttribs["rc_$field"];
+ }
+ # ...more fixups (NULL fields)
+ foreach ( [ 'old_len', 'new_len' ] as $field ) {
+ $this->mAttribs["rc_$field"] = isset( $this->mAttribs["rc_$field"] )
+ ? (int)$this->mAttribs["rc_$field"]
+ : null;
+ }
+
# If our database is strict about IP addresses, use NULL instead of an empty string
if ( $dbw->strictIPs() && $this->mAttribs['rc_ip'] == '' ) {
unset( $this->mAttribs['rc_ip'] );
$title = $this->getTitle();
// Never send an RC notification email about categorization changes
- if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) {
- if ( Hooks::run( 'AbortEmailNotification', [ $editor, $title, $this ] ) ) {
- # @todo FIXME: This would be better as an extension hook
+ if (
+ $this->mAttribs['rc_type'] != RC_CATEGORIZE &&
+ Hooks::run( 'AbortEmailNotification', [ $editor, $title, $this ] )
+ ) {
+ // @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,
$this->mAttribs['rc_last_oldid'],
$this->mExtra['pageStatus']
);
- }
+ } );
}
}
'pageStatus' => 'changed'
];
- DeferredUpdates::addCallableUpdate( function() use ( $rc, $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::addCallableUpdate(
+ function () use ( $rc, $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 $rc;
}
'pageStatus' => 'created'
];
- DeferredUpdates::addCallableUpdate( function() use ( $rc, $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::addCallableUpdate(
+ function () use ( $rc, $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 $rc;
}
'rc_comment' => $logComment,
'rc_this_oldid' => $revId,
'rc_last_oldid' => 0,
- 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
+ 'rc_bot' => $user->isAllowed( 'bot' ) ? (int)$wgRequest->getBool( 'bot', true ) : 0,
'rc_ip' => self::checkIPAddress( $ip ),
'rc_patrolled' => $markPatrolled ? 1 : 0,
'rc_new' => 0, # obsolete