Shadab
Well-known member
In XenForo_DataWriter_Forum class, theres this method updateCountersAfterDiscussionSave() which gets called after a discussion is inserted/updated so that the parent node can update the denormalized data accordingly.
I'm a bit confused as to why a separate call to updateLastPost() method, which executes 1 query to fetch the data, is needed. If I understand correctly, this only runs if the last_post_id or title fields have changed. But aren't the updated fields accessible directly from the $discussionDw ?
I'm a bit confused as to why a separate call to updateLastPost() method, which executes 1 query to fetch the data, is needed. If I understand correctly, this only runs if the last_post_id or title fields have changed. But aren't the updated fields accessible directly from the $discussionDw ?
PHP:
else if ($discussionDw->get('discussion_state') == 'visible'
&& $discussionDw->getExisting('discussion_state') == 'visible'
&& $discussionDw->getExisting('last_post_id') == $this->get('last_post_id')
&& ($discussionDw->isChanged('last_post_id') || $discussionDw->isChanged('title'))
)
{
$this->updateLastPost();
}