From: Alexander Ebert Date: Thu, 26 Mar 2015 18:08:42 +0000 (+0100) Subject: Working around a few possible deadlocks by sorting values X-Git-Tag: 2.1.2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8518f3636eae69065e52ff7c75208ed34fa6f87c;p=GitHub%2FWoltLab%2FWCF.git Working around a few possible deadlocks by sorting values --- diff --git a/wcfsetup/install/files/lib/data/user/notification/UserNotificationAction.class.php b/wcfsetup/install/files/lib/data/user/notification/UserNotificationAction.class.php index ea76e06ac7..4079a70679 100644 --- a/wcfsetup/install/files/lib/data/user/notification/UserNotificationAction.class.php +++ b/wcfsetup/install/files/lib/data/user/notification/UserNotificationAction.class.php @@ -112,6 +112,17 @@ class UserNotificationAction extends AbstractDatabaseObjectAction { ); } + usort($notifications, function ($a, $b) { + if ($a['object']->notificationID == $b['object']->notificationID) { + return 0; + } + else if ($a['object']->notificationID < $b['object']->notificationID) { + return -1; + } + + return 1; + }); + // insert author $sql = "INSERT IGNORE INTO wcf".WCF_N."_user_notification_author (notificationID, authorID, time) diff --git a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php index 5f73d89ddc..de3c8617ff 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -162,6 +162,8 @@ class UserStorageHandler extends SingletonFactory { $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($field)); + ksort($this->cache, SORT_NATURAL); + foreach ($this->cache as $userID => $fields) { if (isset($fields[$field])) { unset($this->cache[$userID][$field]); @@ -181,6 +183,9 @@ class UserStorageHandler extends SingletonFactory { WHERE userID = ? AND field = ?"; $statement = WCF::getDB()->prepareStatement($sql); + + ksort($this->resetFields, SORT_NATURAL); + foreach ($this->resetFields as $userID => $fields) { foreach ($fields as $field) { $statement->execute(array( @@ -214,7 +219,11 @@ class UserStorageHandler extends SingletonFactory { VALUES (?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); + ksort($this->updateFields, SORT_NATURAL); + foreach ($this->updateFields as $userID => $fieldValues) { + ksort($fieldValues, SORT_STRING); + foreach ($fieldValues as $field => $fieldValue) { $statement->execute(array( $userID,