From c673c478eec1889a4ddc0fa0036d8b1764dcf1e3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 3 Apr 2023 00:03:32 -0400 Subject: [PATCH 1/2] Ward against missing plink in createSharedBlockByArray - Address https://github.com/friendica/friendica/issues/12486#issuecomment-1492984224 - Add logging to troubleshoot the issue --- src/Model/Item.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index af47b643cf..5ba8ae1bf2 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3042,7 +3042,11 @@ class Item } if (!empty($quote_uri_id)) { - $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item); + if (isset($shared_item['plink'])) { + $item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item); + } else { + DI::logger()->warning('Missing plink in shared item', ['item' => $item, 'shared' => $shared, 'quote_uri_id' => $quote_uri_id, 'shared_item' => $shared_item]); + } } if (!empty($shared_item['uri-id'])) { From e7628af15ff4cf50ba23c064dacd610618ffdd5d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 3 Apr 2023 00:05:40 -0400 Subject: [PATCH 2/2] Ward against nonexistant item in Item::prepareBody - Address https://github.com/friendica/friendica/issues/12486#issuecomment-1492984392 --- src/Model/Item.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Model/Item.php b/src/Model/Item.php index 5ba8ae1bf2..aa33418599 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -31,6 +31,7 @@ use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Delivery; @@ -1394,10 +1395,16 @@ class Item * * @param integer $uri_id * @return void + * @throws InternalServerErrorException + * @throws \ImagickException */ public static function updateDisplayCache(int $uri_id) { $item = Post::selectFirst(self::DISPLAY_FIELDLIST, ['uri-id' => $uri_id]); + if (!$item) { + return; + } + self::prepareBody($item, false, false, true); }