Fixed Entity User::message_count not updated when a new post is added, but DB is updated

Affected version
2.1.3

Xon

Well-known member
When a user posts a new thread, their message counter isn't incremented. But when the thread is deleted, then the first post decrements the total message counter including the previously uncounted first post. Same for moves in/out of a counted forum.

This appears to be because threadMadeVisible() is only called on update, and not new threads.


Post::adjustUserMessageCountIfNeeded is directly editing the DB for the user record, and thus the in-memory visitor entity record isn't being updated as expected, a page reload 'fixes' it by causing the db record to be re-read.

This can cause some minor confusion if an add-on tries to interact with the user's message_count in the same request
 
Last edited:

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.4).

Change log:
Ensure message_count field is updated in cached entities when posts inserted/deleted
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top