Lack of interest Ability to add new rebuild tasks to XF\Job\User

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

DragonByte Tech

Well-known member
The cron job XF\Job\User's rebuildById function does not allow for add-ons to add their own custom rebuild features, without overwriting the whole method.

This can be fixed extremely easily:
PHP:
    protected function rebuildById($id)
    {
        /** @var \XF\Entity\User $user */
        $user = $this->app->em()->find('XF:User', $id, ['Profile']);
        if (!$user)
        {
            return;
        }

        $db = $this->app->db();

        $db->beginTransaction();

        $this->updateColumns($user);

        $user->save(true, false);

        $this->performRebuildTasks($user);

        $db->commit();
    }

    protected function updateColumns(\XF\Entity\User $user)
    {
        $user->alerts_unviewed = $this->app->finder('XF:UserAlert')
            ->where('alerted_user_id', $user->user_id)
            ->where('view_date', 0)
            ->total();

        $user->alerts_unread = $this->app->finder('XF:UserAlert')
            ->where('alerted_user_id', $user->user_id)
            ->where('read_date', 0)
            ->total();

        $user->conversations_unread = $this->app->finder('XF:ConversationUser')
            ->with('Master', true)
            ->with('Recipient', true)
            ->where('owner_user_id', $user->user_id)
            ->where('is_unread', 1)
            ->total();
    }

    protected function performRebuildTasks(\XF\Entity\User $user)
    {
        $user->rebuildUserGroupRelations(false);
        $user->rebuildPermissionCombination();
        $user->rebuildDisplayStyleGroup();
        $user->rebuildWarningPoints();

        $user->Profile->rebuildUserFieldValuesCache();
    }
 
Upvote 6
This suggestion has been closed. Votes are no longer accepted.
Top Bottom