aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/access.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2012-01-22 19:53:34 -0500
committercash <cash.costello@gmail.com>2012-01-22 19:53:34 -0500
commiteb8e9f587a4424918306b8ded8c29cc44e6a6e6e (patch)
treea07f0ad238874b21a853173507d51019c07900b2 /engine/lib/access.php
parent8d62572ff8c2b5bde2c2a933c5b0268d5984a879 (diff)
downloadelgg-eb8e9f587a4424918306b8ded8c29cc44e6a6e6e.tar.gz
elgg-eb8e9f587a4424918306b8ded8c29cc44e6a6e6e.tar.bz2
Fixes #4295 using on duplicate key to not fail when adding the same user more than once to an access collection
Diffstat (limited to 'engine/lib/access.php')
-rw-r--r--engine/lib/access.php4
1 files changed, 3 insertions, 1 deletions
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;