From 79af93405b085b818a2d72f04e759a0a33b2b9bc Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Oct 2020 17:57:24 +0000 Subject: [PATCH 1/2] Update the "commented" field only on several verbs --- src/Model/Item.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index dfea29681..f47e5feec 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1828,8 +1828,6 @@ class Item $notify_type = Delivery::POST; } - $like_no_comment = DI::config()->get('system', 'like_no_comment'); - DBA::transaction(); if (!in_array($item['verb'], self::ACTIVITIES)) { @@ -1940,8 +1938,15 @@ class Item $item['parent'] = $parent_id; // update the commented timestamp on the parent - // Only update "commented" if it is really a comment - if (($item['gravity'] != GRAVITY_ACTIVITY) || !$like_no_comment) { + if (DI::config()->get('system', 'like_no_comment')) { + // Update when it is a comment + $update_commented = in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]); + } else { + // Update when it isn't a follow or tag verb + $update_commented = !in_array($item['verb'], [Activity::FOLLOW, Activity::TAG]); + } + + if ($update_commented) { DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); } else { DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); From 77fcdede9be4c16143ea06a98bc6c7d0b7d60838 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 5 Oct 2020 18:11:05 +0000 Subject: [PATCH 2/2] Fix tests --- src/Model/Item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index f47e5feec..609535974 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1840,6 +1840,7 @@ class Item } $body = $item['body']; + $verb = $item['verb']; // We just remove everything that is content foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) { @@ -1943,7 +1944,7 @@ class Item $update_commented = in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]); } else { // Update when it isn't a follow or tag verb - $update_commented = !in_array($item['verb'], [Activity::FOLLOW, Activity::TAG]); + $update_commented = !in_array($verb, [Activity::FOLLOW, Activity::TAG]); } if ($update_commented) {