diff options
author | Mario <mario@mariovavti.com> | 2021-04-19 10:41:28 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-04-19 10:41:28 +0000 |
commit | c95a6fe1e5fb67c98e18096ed5c8759a2b554324 (patch) | |
tree | 08b3a58287ee9f890eb06661cc41a90595765ed6 /include/import.php | |
parent | 88f7c2041d74d82db5c84b45f30e1eb64dfcc216 (diff) | |
download | volse-hubzilla-c95a6fe1e5fb67c98e18096ed5c8759a2b554324.tar.gz volse-hubzilla-c95a6fe1e5fb67c98e18096ed5c8759a2b554324.tar.bz2 volse-hubzilla-c95a6fe1e5fb67c98e18096ed5c8759a2b554324.zip |
import_items(): make sure we compare the correct revision and only call item_store_update() if edited timestamp of the received item > stored item timestamp
Diffstat (limited to 'include/import.php')
-rw-r--r-- | include/import.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/import.php b/include/import.php index 8ce582ede..ea324ccb5 100644 --- a/include/import.php +++ b/include/import.php @@ -708,12 +708,12 @@ function import_items($channel, $items, $sync = false, $relocate = null) { $allow_code = channel_codeallowed($channel['channel_id']); $deliver = false; // Don't deliver any messages or notifications when importing - foreach($items as $i) { $item_result = false; $item = get_item_elements($i,$allow_code); - if(! $item) + if(! $item) { continue; + } // deprecated @@ -724,17 +724,18 @@ function import_items($channel, $items, $sync = false, $relocate = null) { item_url_replace($channel,$item,$relocate['url'],z_root(),$relocate['channel_address']); } - $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", + $r = q("select id, edited from item where mid = '%s' and uid = %d and revision = %d limit 1", dbesc($item['mid']), - intval($channel['channel_id']) + intval($channel['channel_id']), + intval($item['revision']) ); if($r) { // flags may have changed and we are probably relocating the post, // so force an update even if we have the same timestamp - if($item['edited'] >= $r[0]['edited']) { - $item['id'] = $r[0]['id']; + if($item['edited'] > $r[0]['edited']) { + $item['id'] = $r[0]['id']; $item['uid'] = $channel['channel_id']; $item_result = item_store_update($item,$allow_code,$deliver); } |