From 047b90e7443584ca71220784a4dcef55e8694856 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 12 Sep 2016 14:23:14 -0700 Subject: [PATCH] Make sure emails from RecentChange::save() are for comitted rows Change-Id: I9086a70348d2f0843527e3805e9f6aef3356ee03 --- includes/changes/RecentChange.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index a5d1fc5f71..8e74674845 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -336,9 +336,13 @@ class RecentChange { $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, @@ -349,7 +353,7 @@ class RecentChange { $this->mAttribs['rc_last_oldid'], $this->mExtra['pageStatus'] ); - } + } ); } } -- 2.20.1