Fixed "Unviewed alerts do not expire."

NamePros

Member
The sentence "Unviewed alerts do not expire" is found on this page: /admin.php?options/list/alerts

Unfortunately, alerts do in fact expire and disappear after a period of time.

Is this a bug in XenForo?
 
No, that as it turns out is intentional, otherwise you could have alerts stored from years ago of users that never visited again.

The bug would be that page saying that, so I'm moving this to bugs.
 
I've adjusted the phrasing here. To be clear, unviewed alerts expire 30 days after they happened.
Despite the purge @ 30 days, it appears that {$visitor.alerts_unread} remains set for the value of unread alerts even beyond 30..
 
Last edited:
how would one increase the max from 30 to 100? i'm guessing this should do it in library/xenforo/model/alerts.php (in xf 1.5), but this is difficult to test, as it's a db purge:

Code:
public function deleteOldUnreadAlerts($dateCut = null)
    {
        /*if ($dateCut === null)
        {
            $dateCut = XenForo_Application::$time - 30 * 86400;
        }*/
        
        $dateCut = XenForo_Application::$time - 100 * 86400;

        $db = $this->_getDb();
        $db->delete('xf_user_alert', 'view_date = 0 AND event_date < '. $db->quote($dateCut));
    }
 
@king8084, rather than commenting out the old code, just change the 30 to a 100. Your code doesn't work quite as intended because it overrides $dateCut if it's explicitly set, though I don't think that scenario ever occurs in vanilla XenForo.
 
@king8084, rather than commenting out the old code, just change the 30 to a 100. Your code doesn't work quite as intended because it overrides $dateCut if it's explicitly set, though I don't think that scenario ever occurs in vanilla XenForo.
it was pretty unclear where $dateCut is set, hence the desire to set it across the board (that, plus the fact that i can't foresee a desire to not have it be consistently set at 100). mind lending some additional knowledge and help me understand why what i have above wouldn't accomplish the intent, even if overkill for situations where dateCut may possibly be set?
 
it was pretty unclear where $dateCut is set,
It actually isn't set anywhere. You can consider the value of $dateCut to always be null in all default usages of that method, therefore I'd just recommend changing the 30 to 100, but indeed what you've done will work if that's what you want to do.
 
Top Bottom