fix: unread notifications are globally cached between users. (#3543)

Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
This commit is contained in:
Sami Mazouz 2022-07-18 15:17:46 +01:00 committed by GitHub
parent 29179e27c6
commit ac23d79fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -449,10 +449,10 @@ class User extends AbstractModel
*/
protected function getUnreadNotifications()
{
static $cached = null;
static $cached = [];
if (is_null($cached)) {
$cached = $this->notifications()
if (! isset($cached[$this->id])) {
$cached[$this->id] = $this->notifications()
->whereIn('type', $this->getAlertableNotificationTypes())
->whereNull('read_at')
->where('is_deleted', false)
@ -460,7 +460,7 @@ class User extends AbstractModel
->get();
}
return $cached;
return $cached[$this->id];
}
/**