Defer publish of recent change for log entries
This defers the publish function of ManualLogEntry, which includes saving the recent change to the db, notification of feeds, auto-patrol and addition of change tags. This way, end users no longer have to wait for those actions to conclude for the request to complete. Bug: T127852 Change-Id: Ida86b7a7383d12695be28338c69b93e8e86d82c9
This commit is contained in:
parent
609cc5702d
commit
51c0f192ea
1 changed files with 29 additions and 27 deletions
|
|
@ -705,39 +705,41 @@ class ManualLogEntry extends LogEntryBase {
|
|||
*
|
||||
* @param int $newId Id of the log entry.
|
||||
* @param string $to One of: rcandudp (default), rc, udp
|
||||
* @return RecentChange|null
|
||||
*/
|
||||
public function publish( $newId, $to = 'rcandudp' ) {
|
||||
$log = new LogPage( $this->getType() );
|
||||
if ( $log->isRestricted() ) {
|
||||
return null;
|
||||
}
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $newId, $to ) {
|
||||
$log = new LogPage( $this->getType() );
|
||||
if ( !$log->isRestricted() ) {
|
||||
$rc = $this->getRecentChange( $newId );
|
||||
|
||||
$rc = $this->getRecentChange( $newId );
|
||||
if ( $to === 'rc' || $to === 'rcandudp' ) {
|
||||
$rc->save( 'pleasedontudp' );
|
||||
}
|
||||
|
||||
if ( $to === 'rc' || $to === 'rcandudp' ) {
|
||||
$rc->save( 'pleasedontudp' );
|
||||
}
|
||||
if ( $to === 'udp' || $to === 'rcandudp' ) {
|
||||
$rc->notifyRCFeeds();
|
||||
}
|
||||
|
||||
if ( $to === 'udp' || $to === 'rcandudp' ) {
|
||||
$rc->notifyRCFeeds();
|
||||
}
|
||||
// Log the autopatrol if the log entry is patrollable
|
||||
if ( $this->getIsPatrollable() &&
|
||||
$rc->getAttribute( 'rc_patrolled' ) === 1
|
||||
) {
|
||||
PatrolLog::record( $rc, true, $this->getPerformer() );
|
||||
}
|
||||
|
||||
// Log the autopatrol if the log entry is patrollable
|
||||
if ( $this->getIsPatrollable() &&
|
||||
$rc->getAttribute( 'rc_patrolled' ) === 1 ) {
|
||||
PatrolLog::record( $rc, true, $this->getPerformer() );
|
||||
}
|
||||
|
||||
// Add change tags to the log entry and (if applicable) the associated revision
|
||||
$tags = $this->getTags();
|
||||
if ( !is_null( $tags ) ) {
|
||||
$rcId = $rc->getAttribute( 'rc_id' );
|
||||
$revId = $this->getAssociatedRevId(); // Use null if $revId is 0
|
||||
ChangeTags::addTags( $tags, $rcId, $revId > 0 ? $revId : null, $newId );
|
||||
}
|
||||
|
||||
return $rc;
|
||||
// Add change tags to the log entry and (if applicable) the associated revision
|
||||
$tags = $this->getTags();
|
||||
if ( !is_null( $tags ) ) {
|
||||
$rcId = $rc->getAttribute( 'rc_id' );
|
||||
$revId = $this->getAssociatedRevId(); // Use null if $revId is 0
|
||||
ChangeTags::addTags( $tags, $rcId, $revId > 0 ? $revId : null, $newId );
|
||||
}
|
||||
}
|
||||
},
|
||||
DeferredUpdates::POSTSEND,
|
||||
wfGetDB( DB_MASTER )
|
||||
);
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue