From bcde6faee04afaa32d0d076df3544b97e401ece1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 21 Jan 2012 19:37:37 +0100 Subject: [PATCH] Use transaction for updates to avoid problems with a race condition --- .../lib/system/user/storage/UserStorageHandler.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 469f2bb2ec..388821558f 100644 --- a/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php @@ -155,6 +155,7 @@ class UserStorageHandler extends SingletonFactory { * Removes and inserts data records on shutdown. */ public function shutdown() { + WCF::getDB()->beginTransaction(); // remove outdated entries if (count($this->resetFields)) { $sql = "DELETE FROM wcf".WCF_N."_user_storage @@ -166,7 +167,7 @@ class UserStorageHandler extends SingletonFactory { foreach ($this->resetFields as $userID => $data) { foreach ($data as $packageID => $fields) { foreach ($fields as $field) { - $statement->execute(array( + $statement->executeUnbuffered(array( $userID, $field, $packageID @@ -186,7 +187,7 @@ class UserStorageHandler extends SingletonFactory { foreach ($this->updateFields as $userID => $data) { foreach ($data as $packageID => $fieldValues) { foreach ($fieldValues as $field => $fieldValue) { - $statement->execute(array( + $statement->executeUnbuffered(array( $userID, $field, $fieldValue, @@ -196,6 +197,7 @@ class UserStorageHandler extends SingletonFactory { } } } + WCF::getDB()->commitTransaction(); $this->resetFields = $this->updateFields = array(); } -- 2.20.1