From a9d114316d9ba423cb7440a78e0190e81d2f9625 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 12 Nov 2020 10:23:50 -0500 Subject: [PATCH] Ensure the parent field isn't set during Item insertion - Avoid a database error if a null value is provided --- src/Model/Item.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 1ccd85c64..4645f553a 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1734,7 +1734,6 @@ class Item // Update the contact relations Contact\Relation::store($toplevel_parent['author-id'], $item['author-id'], $item['created']); - unset($item['parent']); unset($item['parent_origin']); } else { $parent_id = 0; @@ -1777,11 +1776,13 @@ class Item $item['parent'] = $parent_id; Hook::callAll('post_local', $item); unset($item['edit']); - unset($item['parent']); } else { Hook::callAll('post_remote', $item); } + // Set after the insert because top-level posts are self-referencing + unset($item['parent']); + if (!empty($item['cancel'])) { Logger::log('post cancelled by addon.'); return 0;