From: Tim Düsterhus Date: Sat, 21 Jan 2012 18:37:37 +0000 (+0100) Subject: Use transaction for updates to avoid problems with a race condition X-Git-Tag: 2.0.0_Beta_1~1365^2~1^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bcde6faee04afaa32d0d076df3544b97e401ece1;p=GitHub%2FWoltLab%2FWCF.git Use transaction for updates to avoid problems with a race condition --- 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(); }