Merge branch 'duplicate_fixes_1' into 'dev'

if we have an uuid deduplicate by uuid otherwise by mid

See merge request hubzilla/core!1573
This commit is contained in:
Max Kostikov 2019-03-25 12:24:36 +01:00
commit c218970890

View File

@ -1930,11 +1930,21 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
if($parent_deleted)
$arr['item_deleted'] = 1;
$r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d and revision = %d LIMIT 1",
dbesc($arr['mid']),
intval($arr['uid']),
intval($arr['revision'])
);
if($arr['uuid']) {
$r = q("SELECT id FROM item WHERE uuid = '%s' AND uid = %d and revision = %d LIMIT 1",
dbesc($arr['uuid']),
intval($arr['uid']),
intval($arr['revision'])
);
}
else {
$r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d and revision = %d LIMIT 1",
dbesc($arr['mid']),
intval($arr['uid']),
intval($arr['revision'])
);
}
if($r) {
logger('duplicate item ignored. ' . print_r($arr,true));
$ret['message'] = 'duplicate post.';