Merge "Define $wgAlwaysUseTidy to false where needed in unit tests"
[lhc/web/wiklou.git] / includes / UserMailer.php
index 01e7132..b9ce9e0 100644 (file)
@@ -152,6 +152,7 @@ class UserMailer {
         * @param $body String: email's text.
         * @param $replyto MailAddress: optional reply-to email (default: null).
         * @param $contentType String: optional custom Content-Type (default: text/plain; charset=UTF-8)
+        * @throws MWException
         * @return Status object
         */
        public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8' ) {
@@ -194,7 +195,7 @@ class UserMailer {
                #  NOTE: To: is for presentation, the actual recipient is specified
                #  by the mailer using the Rcpt-To: header.
                #
-               # Subject: 
+               # Subject:
                #  PHP mail() second argument to pass the subject, passing a Subject
                #  as an additional header will result in a duplicate header.
                #
@@ -228,7 +229,7 @@ class UserMailer {
                if ( is_array( $wgSMTP ) ) {
                        #
                        # PEAR MAILER
-                       # 
+                       #
 
                        if ( function_exists( 'stream_resolve_include_path' ) ) {
                                $found = stream_resolve_include_path( 'Mail.php' );
@@ -260,7 +261,7 @@ class UserMailer {
                        }
 
                        # Split jobs since SMTP servers tends to limit the maximum
-                       # number of possible recipients.        
+                       # number of possible recipients.
                        $chunks = array_chunk( $to, $wgEnotifMaxRecips );
                        foreach ( $chunks as $chunk ) {
                                $status = self::sendWithPear( $mail_object, $chunk, $headers, $body );
@@ -272,8 +273,8 @@ class UserMailer {
                        }
                        wfRestoreWarnings();
                        return Status::newGood();
-               } else  {
-                       # 
+               } else {
+                       #
                        # PHP mail()
                        #
 
@@ -446,19 +447,23 @@ class EmailNotification {
                                $watchers[] = intval( $row->wl_user );
                        }
                        if ( $watchers ) {
-                               // Update wl_notificationtimestamp for all watching users except
-                               // the editor
-                               $dbw->begin( __METHOD__ );
-                               $dbw->update( 'watchlist',
-                                       array( /* SET */
-                                               'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
-                                       ), array( /* WHERE */
-                                               'wl_user' => $watchers,
-                                               'wl_namespace' => $title->getNamespace(),
-                                               'wl_title' => $title->getDBkey(),
-                                       ), __METHOD__
+                               // Update wl_notificationtimestamp for all watching users except the editor
+                               $fname = __METHOD__;
+                               $dbw->onTransactionIdle(
+                                       function() use ( $dbw, $timestamp, $watchers, $title, $fname ) {
+                                               $dbw->begin( $fname );
+                                               $dbw->update( 'watchlist',
+                                                       array( /* SET */
+                                                               'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
+                                                       ), array( /* WHERE */
+                                                               'wl_user'      => $watchers,
+                                                               'wl_namespace' => $title->getNamespace(),
+                                                               'wl_title'     => $title->getDBkey(),
+                                                       ), $fname
+                                               );
+                                               $dbw->commit( $fname );
+                                       }
                                );
-                               $dbw->commit( __METHOD__ );
                        }
                }