Bsitu has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64009


Change subject: (bug 48521) Echo should not implicitly commit other transaction
......................................................................

(bug 48521) Echo should not implicitly commit other transaction

Change-Id: I30abd7155b12370aea97218080cc8798f7f0df55
---
M includes/DbEchoBackend.php
1 file changed, 25 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/09/64009/1

diff --git a/includes/DbEchoBackend.php b/includes/DbEchoBackend.php
index 68d9026..f257df0 100644
--- a/includes/DbEchoBackend.php
+++ b/includes/DbEchoBackend.php
@@ -10,24 +10,32 @@
         */
        public function createNotification( $row ) {
                $dbw = MWEchoDbFactory::getDB( DB_MASTER );
-               $dbw->begin( __METHOD__ );
-               // reset the base if this notification has a display hash
-               if ( $row['notification_bundle_display_hash'] ) {
-                       $dbw->update(
-                               'echo_notification',
-                               array( 'notification_bundle_base' => 0 ),
-                               array(
-                                       'notification_user' => 
$row['notification_user'],
-                                       'notification_bundle_display_hash' => 
$row['notification_bundle_display_hash'],
-                                       'notification_bundle_base' => 1
-                               ),
-                               __METHOD__
-                       );
-               }
 
-               $row['notification_timestamp'] = $dbw->timestamp( 
$row['notification_timestamp'] );
-               $dbw->insert( 'echo_notification', $row, __METHOD__ );
-               $dbw->commit( __METHOD__ );
+               $fname = __METHOD__;
+               $dbw->onTransactionIdle(
+                       function() use ( $dbw, $row, $fname ) {
+                               $dbw->begin( $fname );
+                               // reset the base if this notification has a 
display hash
+                               if ( $row['notification_bundle_display_hash'] ) 
{
+                                       $dbw->update(
+                                               'echo_notification',
+                                               array( 
'notification_bundle_base' => 0 ),
+                                               array(
+                                                       'notification_user' => 
$row['notification_user'],
+                                                       
'notification_bundle_display_hash' => $row['notification_bundle_display_hash'],
+                                                       
'notification_bundle_base' => 1
+                                               ),
+                                               $fname
+                                       );
+                               }
+
+                               $row['notification_timestamp'] = 
$dbw->timestamp( $row['notification_timestamp'] );
+                               $dbw->insert( 'echo_notification', $row, $fname 
);
+                               $dbw->commit( $fname );
+                       }
+               );
+               
+               
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/64009
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I30abd7155b12370aea97218080cc8798f7f0df55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to