From ae4aeb4b1e57855d8f1788e74c56b57377df59aa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 26 Oct 2018 13:00:26 -0700 Subject: delivery chain linkage messed up if original post was edited --- include/items.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 58461cc3a..cae380b01 100755 --- a/include/items.php +++ b/include/items.php @@ -2150,6 +2150,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { unset($arr['created']); unset($arr['author_xchan']); unset($arr['owner_xchan']); + unset($arr['source_xchan']); unset($arr['thr_parent']); unset($arr['llink']); @@ -2514,7 +2515,7 @@ function tag_deliver($uid, $item_id) { // Just start the second delivery chain to deliver the updated post // after resetting ownership and permission bits logger('updating edited tag_deliver post for ' . $u[0]['channel_address']); - start_delivery_chain($u[0], $item, $item_id, 0); + start_delivery_chain($u[0], $item, $item_id, 0, true); return; } @@ -2941,7 +2942,7 @@ function tgroup_check($uid, $item) { * @param int $item_id * @param boolean $parent */ -function start_delivery_chain($channel, $item, $item_id, $parent) { +function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) { $sourced = check_item_source($channel['channel_id'],$item); @@ -2950,7 +2951,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { intval($channel['channel_id']), dbesc(($item['source_xchan']) ? $item['source_xchan'] : $item['owner_xchan']) ); - if($r) { + if($r && ! $edit) { $t = trim($r[0]['src_tag']); if($t) { $tags = explode(',',$t); @@ -3017,9 +3018,17 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { } else { $item_uplink = 1; - $r = q("update item set source_xchan = owner_xchan where id = %d", - intval($item_id) - ); + + // if this is an edit, item_store_update() will have already updated the item + // with the correct value for source_xchan (by ignoring it). We cannot set to owner_xchan + // in this case because owner_xchan will point to the parent of this chain + // and not the original sender. + + if(! $edit) { + $r = q("update item set source_xchan = owner_xchan where id = %d", + intval($item_id) + ); + } } $title = $item['title']; -- cgit v1.2.3