From eb8e9f587a4424918306b8ded8c29cc44e6a6e6e Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 22 Jan 2012 19:53:34 -0500 Subject: Fixes #4295 using on duplicate key to not fail when adding the same user more than once to an access collection --- engine/lib/access.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engine/lib/access.php') diff --git a/engine/lib/access.php b/engine/lib/access.php index dba1e1ec6..6be252c6a 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -671,8 +671,10 @@ function add_user_to_access_collection($user_guid, $collection_id) { return false; } + // if someone tries to insert the same data twice, we do a no-op on duplicate key $q = "INSERT INTO {$CONFIG->dbprefix}access_collection_membership - SET access_collection_id = {$collection_id}, user_guid = {$user_guid}"; + SET access_collection_id = $collection_id, user_guid = $user_guid + ON DUPLICATE KEY UPDATE user_guid = user_guid"; $result = insert_data($q); return $result !== false; -- cgit v1.2.3