Label counter doesn't update when count goes down to zero

Describe the problem you’re having:

Label counter doesn’t update when count goes down to zero

If possible include steps to reproduce the problem:

  1. Create a label “testlabel”
  2. Assign this label to an already read article X
  3. Switch feed column to “unhide read feeds” mode via “f a” keycommand
  4. Article count for testlabel is correctly shown as “1”
  5. Remove “testlabel” from article X
  6. Article count for testlabel is remains 1, even though there are no articles labelled with this label
    To clear article count one have to refresh browser page

tt-rss version (including git commit id):

tt-rss git version 5497a137de85d2412b1381c457127e38ed1f8768

Platform (i.e. Linux distro, PHP, PostgreSQL, etc) versions:

tt-rss@in:/var/www/tt-rss$ cat /etc/debian_version
10.5
tt-rss@in:/var/www/tt-rss$ php --version
PHP 7.3.19-1~deb10u1 (cli) (built: Jul 5 2020 06:46:45) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright © 1998-2018 Zend Technologies
with Zend OPcache v7.3.19-1~deb10u1, Copyright © 1999-2018, by Zend Technologies
tt-rss@in:/var/www/tt-rss$ psql --version
psql (PostgreSQL) 11.7 (Debian 11.7-0+deb10u1)

Please provide any additional information below:

The cause seems to be that after removing a label browser issues a “getAllCounters” request to backend, and backend returns counters only for those labels that have any articles in them, “testlabel” is missing from backend response. After making a following change:

diff --git a/classes/counters.php b/classes/counters.php
index d8ed27621..4230fa4d4 100644
--- a/classes/counters.php
+++ b/classes/counters.php
@@ -234,8 +234,8 @@ class Counters {
                                COUNT(u1.unread) AS total
                        FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
                                (ttrss_labels2.id = label_id)
-                                       LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id
-                                               WHERE ttrss_labels2.owner_uid = :uid AND u1.owner_uid = :uid
+                                       LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id AND u1.owner_uid = :uid
+                                               WHERE ttrss_labels2.owner_uid = :uid
                                                        GROUP BY ttrss_labels2.id, ttrss_labels2.caption");
                $sth->execute([":uid" => $_SESSION['uid']]);

error seems to be fixed in my instance of tt-rss.
I’m not sure, though if that’s correct way to fix this problem – my instance is single-user, and with multiuser tt-rss this change might break counters

thanks for reporting this. i’ll take make a note to test your proposed changes to see if anything breaks.

should be merged now - https://git.tt-rss.org/fox/tt-rss/commit/67f02e2aa7b246ef7ca2b2aa4c62e2826327d219

i don’t think inner owner_uid check on u1 is even necessary, outer check on base labels table should be enough (the UI only allows assigning articles to labels you own). might as well keep it though.

Great, thanks!
Thanks a ton for great software, btw!