• REGISTRATION REQUIREMENTS:

    Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Fixed BlogEntry Watch Comment Notifier loads wrong read timestamps

Kirby

Member
AMS Premium
CAS Premium
IMS Premium
LD Premium
RMS Premium
SC Premium
UBS Premium
UBS Version
2.3.11
XenForo Version
2.3.10
PHP Version
8.3.30
Database & Version
MariaDB 10.11.14
Are there any errors being throw?
No
We are getting complaints from users that watched blog entry comment notifications don't work (especially for users who were the last to comment on a blog entry and didn't view the blog entry again after posting the comment).

Looking at the code it seems to me like the notifier loads the wrong read timestamps:

PHP:
$readDates = $db->fetchPairs("
        SELECT user.user_id,
                GREATEST(
                        COALESCE(blog_entry_read.blog_entry_read_date, 0),
                        ?
                )
        FROM xf_user AS user
        LEFT JOIN xf_xa_ubs_blog_entry_read AS blog_entry_read ON
                (blog_entry_read.user_id = user.user_id AND blog_entry_read.blog_entry_id = ?)
        WHERE user.user_id IN (" . $db->quote($userIds) . ")
", [$autoReadDate, $comment->blog_entry_id]);

As far as I understand the code, this gets the timestaps for the blog entries, not for blog entry comments.

So shouldn't this be smth. like
PHP:
$readDates = $db->fetchPairs("
        SELECT user.user_id,
                GREATEST(
                        COALESCE(blog_entry_comment_read.comment_read_date, 0),
                        ?
                )
        FROM xf_user AS user
        LEFT JOIN xf_xa_ubs_comment_read AS blog_entry_comment_read ON
                (blog_entry_comment_read.user_id = user.user_id AND blog_entry_comment_read.blog_entry_id = ?)
        WHERE user.user_id IN (" . $db->quote($userIds) . ")
", [$autoReadDate, $comment->blog_entry_id]);
instead?
 
Last edited:
comment notifications don't work
I don't know whether this statement means that alerts are not being sent or if the alerts are being sent, but are being aggressively marked as read before the user actually sees them. I had someone just the other day say that users were not getting comment alerts, but it turned out they were getting comment alerts and they just didn't notice them because of the alerts being marked as read and the users didn't notice them (the alerts didn't stick out as unread).

Could you please clarify which one it is? Thank you!
 
No alerts are sent.

IIRC you can reproduce the bug this way:
  1. Enable the notification
  2. Watch an entry
  3. Go to its last comment page and make sure it has less than perpage -1 comments
  4. Post a comment
  5. Leave the page
  6. Post a new comment using another account
After step 6) the first account does not get an alert.

I've patched the code as described and user complaints have stopped since.
 
Last edited:
  • Like
Reactions: Bob
I've patched the code as described and user complaints have stopped since.
I have no problem making the changes in the upcoming maintenance release (later this week), I trust your judgement ;)

I've marked this as "Fixed" and used your solution. Thank you!
 
Last edited:
Back
Top