From a5ececbb7e54897c461b7c1f3c1eb99a361a1fb2 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Fri, 24 Aug 2018 06:15:12 -0400 Subject: [PATCH] Initialize $success Followup I85452d0f0afe974d26a575e000f6ae2ceeddf06c * initialize "$success = true" before using it in a loop to keep track of the overall success of all batches. * Add check for readOnly db in markUnRead() and markAllRead(), like it was done in markRead() Bug: T202672 Change-Id: Ifdfa93059268d5b02ba3e0e885661ce593845791 --- includes/gateway/UserNotificationGateway.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/gateway/UserNotificationGateway.php b/includes/gateway/UserNotificationGateway.php index 2b4f8011f..7ee237044 100644 --- a/includes/gateway/UserNotificationGateway.php +++ b/includes/gateway/UserNotificationGateway.php @@ -91,7 +91,11 @@ class EchoUserNotificationGateway { } $dbw = $this->getDB( DB_MASTER ); + if ( $dbw->isReadOnly() ) { + return false; + } + $success = true; foreach ( array_chunk( $eventIDs, $wgUpdateRowsPerQuery ) as $batch ) { $success = $dbw->update( self::$notificationTable, @@ -114,6 +118,9 @@ class EchoUserNotificationGateway { */ public function markAllRead() { $dbw = $this->getDB( DB_MASTER ); + if ( $dbw->isReadOnly() ) { + return false; + } return $dbw->update( self::$notificationTable,