mirror of
https://github.com/flarum/core.git
synced 2025-08-02 22:47:33 +02:00
fix: unread notifications are globally cached between users. (#3543)
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
This commit is contained in:
@@ -449,10 +449,10 @@ class User extends AbstractModel
|
|||||||
*/
|
*/
|
||||||
protected function getUnreadNotifications()
|
protected function getUnreadNotifications()
|
||||||
{
|
{
|
||||||
static $cached = null;
|
static $cached = [];
|
||||||
|
|
||||||
if (is_null($cached)) {
|
if (! isset($cached[$this->id])) {
|
||||||
$cached = $this->notifications()
|
$cached[$this->id] = $this->notifications()
|
||||||
->whereIn('type', $this->getAlertableNotificationTypes())
|
->whereIn('type', $this->getAlertableNotificationTypes())
|
||||||
->whereNull('read_at')
|
->whereNull('read_at')
|
||||||
->where('is_deleted', false)
|
->where('is_deleted', false)
|
||||||
@@ -460,7 +460,7 @@ class User extends AbstractModel
|
|||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cached;
|
return $cached[$this->id];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user