From 08bf19082c516a9192ae6d2dbbfccf9a174431f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 8 May 2018 20:20:15 +0000 Subject: [PATCH] Ensure that there will always be an author-id and owner-id in the items --- src/Model/Item.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index c50e669ad..44275ae44 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -488,14 +488,20 @@ class Item extends BaseObject // The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes $item["contact-id"] = self::contactId($item); - $item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item["author-link"])); + $default = ['url' => $item['author-link'], 'name' => $item['author-name'], + 'avatar' => $item['author-avatar'], 'network' => $item['network']]; + + $item['author-id'] = defaults($item, 'author-id', Contact::getIdForURL($item["author-link"], 0, false, $default)); if (Contact::isBlocked($item["author-id"])) { logger('Contact '.$item["author-id"].' is blocked, item '.$item["uri"].' will not be stored'); return 0; } - $item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item["owner-link"])); + $default = ['url' => $item['owner-link'], 'name' => $item['owner-name'], + 'avatar' => $item['owner-avatar'], 'network' => $item['network']]; + + $item['owner-id'] = defaults($item, 'owner-id', Contact::getIdForURL($item["owner-link"], 0, false, $default)); if (Contact::isBlocked($item["owner-id"])) { logger('Contact '.$item["owner-id"].' is blocked, item '.$item["uri"].' will not be stored');