]> git.mxchange.org Git - friendica.git/commitdiff
Ensure the parent field isn't set during Item insertion
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 12 Nov 2020 15:23:50 +0000 (10:23 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 14 Nov 2020 15:08:51 +0000 (10:08 -0500)
- Avoid a database error if a null value is provided

src/Model/Item.php

index 1ccd85c64c670000920e776dc505f27d4da4b812..4645f553adee998ea3264a26c387001b5ddc9e9e 100644 (file)
@@ -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;