From c6ac4387350eefce8ba68485c49ba8da60ff437b Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 3 Oct 2011 06:04:17 -0700 Subject: [PATCH] item_store: prevent storing a duplicate item with same uri+uid --- include/items.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/items.php b/include/items.php index 32f0728c33..d907aeddba 100644 --- a/include/items.php +++ b/include/items.php @@ -807,6 +807,14 @@ function item_store($arr,$force_parent = false) { } } + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($arr['uri']), + dbesc($arr['uid']) + ); + if($r && count($r)) { + logger('item-store: duplicate item ignored. ' . print_r($arr,true)); + return 0; + } call_hooks('post_remote',$arr);