From 20b93306ad277b79126f5ebf23a09ee379e55c3f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 31 May 2020 14:38:00 +0000 Subject: [PATCH 1/2] Handling situations where "vid" is empty --- include/conversation.php | 2 +- mod/ping.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 6fdfd30b4..e623c9320 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -771,7 +771,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid) $items = []; foreach ($parents AS $parent) { - $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND `vid` != ?", + $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)", $parent['uri'], $uid, Verb::getID(Activity::FOLLOW)]; $items = conversation_fetch_items($parent, $items, $condition, $block_authors, $params); } diff --git a/mod/ping.php b/mod/ping.php index 73e759107..6b3b015ac 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -136,7 +136,7 @@ function ping_init(App $a) $notifs = ping_get_notifications(local_user()); - $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND `vid` != ?", + $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`vid` != ? OR `vid` IS NULL)", local_user(), local_user(), Verb::getID(Activity::FOLLOW)]; $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar', 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity']; From 7ac4a08e1b6981be6178f85381ad1827d986d6b1 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 31 May 2020 15:48:31 +0000 Subject: [PATCH 2/2] Additional "is null" check in post update / create the "vid" if needed --- src/Database/PostUpdate.php | 6 +++--- src/Model/Item.php | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index a3b967d3b..de584238d 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -831,7 +831,7 @@ class PostUpdate } /** - * update the "vid" (verb) field in the item table + * update the "vid" (verb) field in the item table * * @return bool "true" when the job is done * @throws \Friendica\Network\HTTPException\InternalServerErrorException @@ -851,10 +851,10 @@ class PostUpdate $start_id = $id; $rows = 0; - $items = DBA::p("SELECT `item`.`id`, `item`.`vid`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity` + $items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity` FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id` LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id` AND `item`.`gravity` = ? - WHERE `item`.`id` >= ? ORDER BY `item`.`id` LIMIT 10000", GRAVITY_ACTIVITY, $id); + WHERE `item`.`id` >= ? AND `item`.`vid` IS NULL ORDER BY `item`.`id` LIMIT 10000", GRAVITY_ACTIVITY, $id); if (DBA::errorNo() != 0) { Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]); diff --git a/src/Model/Item.php b/src/Model/Item.php index b4d22055b..7a965f80b 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -72,7 +72,7 @@ class Item 'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish', 'event-summary', 'event-desc', 'event-location', 'event-type', 'event-nofinish', 'event-adjust', 'event-ignore', 'event-id', - 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed', 'activity' + 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed' ]; // Field list that is used to deliver items via the protocols @@ -285,6 +285,10 @@ class Item } } + if (array_key_exists('vid', $row) && is_null($row['vid']) && !empty($row['verb'])) { + $row['vid'] = Verb::getID($row['verb']); + } + if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) { // Build the file string out of the term entries if (array_key_exists('file', $row) && empty($row['file'])) { @@ -1777,7 +1781,7 @@ class Item // Check for hashtags in the body and repair or add hashtag links self::setHashtags($item); - + // Fill the cache field self::putInCache($item); @@ -1796,12 +1800,14 @@ class Item } $body = $item['body']; - + // We just remove everything that is content foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) { unset($item[$field]); } + unset($item['activity']); + // Filling item related side tables // Diaspora signature