Skip to content

Commit

Permalink
Merge branch '5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravatronics committed Apr 15, 2021
2 parents 5f9ea37 + 0027bc9 commit 18eb3f3
Showing 1 changed file with 16 additions and 17 deletions.
Expand Up @@ -264,30 +264,29 @@ public function markAllAsConfirmed()
]);
$notificationIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);

// Step 2) Mark the notifications as read.
$condition = new PreparedStatementConditionBuilder();
$condition->add('notificationID IN (?)', [$notificationIDs]);
if (!empty($notificationIDs)) {
// Step 2) Mark the notifications as read.
$condition = new PreparedStatementConditionBuilder();
$condition->add('notificationID IN (?)', [$notificationIDs]);

$sql = "UPDATE wcf" . WCF_N . "_user_notification
$sql = "UPDATE wcf" . WCF_N . "_user_notification
SET confirmTime = ?
{$condition}";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(\array_merge(
[TIME_NOW],
$condition->getParameters()
));
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(\array_merge([TIME_NOW], $condition->getParameters()));

// Step 3) Delete notification_to_user assignments (mimic legacy notification system)
// Step 3) Delete notification_to_user assignments (mimic legacy notification system)

// This conditions technically is not required, because notificationIDs are unique.
// As this is not enforced at the database layer we play safe until this legacy table
// finally is removed.
$condition->add('userID = ?', [WCF::getUser()->userID]);
// This conditions technically is not required, because notificationIDs are unique.
// As this is not enforced at the database layer we play safe until this legacy table
// finally is removed.
$condition->add('userID = ?', [WCF::getUser()->userID]);

$sql = "DELETE FROM wcf" . WCF_N . "_user_notification_to_user
$sql = "DELETE FROM wcf" . WCF_N . "_user_notification_to_user
{$condition}";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($condition->getParameters());
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($condition->getParameters());
}

// Step 4) Clear cached values.
UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'userNotificationCount');
Expand Down

0 comments on commit 18eb3f3

Please sign in to comment.