Digests

Issue with negative private message counts - Digests

Issue with negative private message counts

by MarkDHamill » Thu Jun 13, 2019 1:10 pm

There is apparently a long-standing bug with digests that can result in negative private message counts on the navigation bar. Apparently the way phpBB counts unread and new private messages is different than my logic. I'm working with a major client on a highly trafficked forum to fully test a solution. If you want to get your counts correct, here is the SQL to use. Change phpbb_ for the table prefix if it differs in your config.php file:

Code: Select all

UPDATE phpbb_users u
SET user_new_privmsg = (SELECT if(sum(pm_new) IS NULL, 0, sum(pm_new))
FROM phpbb_privmsgs_to pt
WHERE pt.user_id = u.user_id AND folder_id IN (-3, -4)),
user_unread_privmsg = (SELECT if(sum(pm_unread) IS NULL, 0, sum(pm_unread))
FROM phpbb_privmsgs_to pt
WHERE pt.user_id = u.user_id AND folder_id <> -2);
This uses logic in the update_pm_counts() function in /includes/functions_privmsgs.php.

Considering how many times this extension and mod has been reviewed over the years it's surprising that it's not been caught and no one has complained.

I'm also moving some SQL inside transactions to ensure consistency when updating both private message and user tables.

These will be addressed in a 3.2.14 release.

It should be noted that this behavior could occur only if you have the checkbox "Mark as read when they appear in the digest" next to the private message setting for Post settings in the Digests user control panel.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4933
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA

Re: Issue with negative private message counts

by MarkDHamill » Fri Jun 14, 2019 9:55 pm

Okay, I figured out the issue and it's an embarrassing bug since version 3.2.12. You should update immediately if you have versions 3.2.12 or 3.2.13 installed. You also need to execute the above SQL. See the topic.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.
User avatar
MarkDHamill
Registered User
Posts: 4933
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA