1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

As Designed Alert Disappeared

Discussion in 'Resolved Bug Reports' started by Daniel Hood, Sep 23, 2013.

  1. Daniel Hood

    Daniel Hood Well-Known Member

    On this site, I just had an alert but when I moused over it nothing was there. It could have possibly been a like -> unlike thing, but it could be some sort of bug. If you want to look in the database for my most recent alert there might be something.
  2. Chris D

    Chris D XenForo Developer Staff Member

    Could be like/unlike. Could be a post that's been deleted. It's usually the expected behaviour.
    Adam Howard likes this.
  3. Digital Doctor

    Digital Doctor Well-Known Member

    I get that if the Alert expired (haven't been back to the forum in a while).
  4. Daniel Hood

    Daniel Hood Well-Known Member

    It definitely didn't expire, I had one from before it showing, and I've gotten a couple since then, now. I thought the model was supposed to remove alerts in a like/unlike situation.
  5. Chris D

    Chris D XenForo Developer Staff Member

    It does. But the alert count is cached in xf_user.

    I don't think that is retrospectively corrected if an alert is removed.
  6. Daniel Hood

    Daniel Hood Well-Known Member

    oh ok. I didn't realize they cached it, I figured this line from the alert datawriter was supposed to correct it:

                    UPDATE xf_user SET
                        alerts_unread = IF(alerts_unread > 0, alerts_unread - 1, 0)
                    WHERE user_id = ?
                ', $this->get('alerted_user_id'));
  7. Chris D

    Chris D XenForo Developer Staff Member

    One scenario this can happen, I think, is if an alert hasn't been deleted, but you're no longer allowed to see it.

    That could be that the post has gone into moderation, been soft deleted, been moved to a forum you don't have permission to view etc.

    The AlertHandler deals with that:

        * Determines if the post is viewable.
        * @see XenForo_AlertHandler_Abstract::canViewAlert()
    public function canViewAlert(array $alert$content, array $viewingUser)
    $content$content$content$null$content['permissions'], $viewingUser
    So, yeah, it's more likely something like that. That happens on the fly as the alerts are fetched:

            foreach ($alerts AS $key => $alert)
    $handler $this->_getAlertHandlerFromCache($alert['content_type']);
                if (!
    $handler || !$handler->canViewAlert($alert$alert['content'], $viewingUser))
    That would leave the user's alert count at an incorrect value.
    Daniel Hood and Adam Howard like this.
  8. Daniel Hood

    Daniel Hood Well-Known Member

    Seems like a possibility; that would have had to have happened super quick though as I was browsing the forums at the time and feel I noticed nearly instantly. Probably not a bug, leaning towards the count was cached which makes that line I posted earlier semi-useless.

Share This Page