From 97fbf70fa6f3556450fd6b815c1fabbd1ee63a06 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Oct 2023 17:06:21 +0000 Subject: [PATCH] Fix: The calculation of unseen circles can now be deactivated again --- database.sql | 4 ++-- src/Model/Circle.php | 9 +++++---- src/Module/Admin/Site.php | 2 +- src/Module/Notifications/Ping.php | 4 ++-- static/dbstructure.config.php | 2 +- update.php | 10 ++++++++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/database.sql b/database.sql index 329381b95b..93cc138967 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ --- Friendica 2023.09-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1534 +-- Friendica 2023.09-rc (Giant Rhubarb) +-- DB_UPDATE_VERSION 1535 -- ------------------------------------------ diff --git a/src/Model/Circle.php b/src/Model/Circle.php index 2b32103db9..92e3ea6560 100644 --- a/src/Model/Circle.php +++ b/src/Model/Circle.php @@ -169,16 +169,17 @@ class Circle * * Count unread items of each circle of the local user * + * @param int $uid * @return array * 'id' => circle id * 'name' => circle name * 'count' => counted unseen circle items * @throws \Exception */ - public static function countUnseen() + public static function countUnseen(int $uid) { $stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`, - (SELECT COUNT(*) FROM `post-user-view` + (SELECT COUNT(*) FROM `post-user` WHERE `uid` = ? AND `unseen` AND `contact-id` IN @@ -188,8 +189,8 @@ class Circle ) AS `count` FROM `group` AS `circle` WHERE `circle`.`uid` = ?;", - DI::userSession()->getLocalUserId(), - DI::userSession()->getLocalUserId() + $uid, + $uid ); return DBA::toArray($stmt); diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 09624dcfc7..a99619c813 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -504,7 +504,7 @@ class Site extends BaseAdmin '$max_display_comments' => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')], '$temppath' => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')], '$only_tag_search' => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')], - '$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_group_counts') ?? DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')], + '$compute_circle_counts' => ['compute_circle_counts', DI::l10n()->t('Generate counts per contact circle when calculating network count'), DI::config()->get('system', 'compute_circle_counts'), DI::l10n()->t('On systems with users that heavily use contact circles the query can be very expensive.')], '$worker_queues' => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)], '$worker_fastlane' => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')], diff --git a/src/Module/Notifications/Ping.php b/src/Module/Notifications/Ping.php index 85b9b4d694..794ca5861a 100644 --- a/src/Module/Notifications/Ping.php +++ b/src/Module/Notifications/Ping.php @@ -152,10 +152,10 @@ class Ping extends BaseModule } } - $compute_circle_counts = $this->config->get('system','compute_group_counts') ?? $this->config->get('system','compute_circle_counts'); + $compute_circle_counts = $this->config->get('system','compute_circle_counts'); if ($network_count && $compute_circle_counts) { // Find out how unseen network posts are spread across circles - foreach (Circle::countUnseen() as $circle_count) { + foreach (Circle::countUnseen($this->session->getLocalUserId()) as $circle_count) { if ($circle_count['count'] > 0) { $circles_unseen[] = $circle_count; } diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 606173b817..682c719919 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -56,7 +56,7 @@ use Friendica\Database\DBA; // This file is required several times during the test in DbaDefinition which justifies this condition if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1534); + define('DB_UPDATE_VERSION', 1535); } return [ diff --git a/update.php b/update.php index 9af01fd0fe..f04a4d5c5f 100644 --- a/update.php +++ b/update.php @@ -1388,5 +1388,15 @@ function update_1531() } DBA::close($threads); + return Update::SUCCESS; +} + +function update_1535() +{ + if (DI::config()->get('system', 'compute_group_counts')) { + DI::config()->set('system', 'compute_circle_counts', true); + } + DI::config()->delete('system', 'compute_group_counts'); + return Update::SUCCESS; } \ No newline at end of file -- 2.39.5