From 5d59d364f82c879b129c07a4872cb2bc53eab053 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Mar 2017 19:04:11 -0500 Subject: [PATCH] Fixes bug preventing proper updating of caches and models due to undefined Auth::user() --- CHANGELOG.md | 1 + app/Observers/ServerObserver.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47cee758..919efdcb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### Fixed * Fixes potential bug with invalid CIDR notation (ex: `192.168.1.1/z`) when adding allocations that could cause over 4 million records to be created at once. +* `[pre.4]` — Fixes bug preventing server updates from occurring by the system due to undefined `Auth::user()` in the event listener. ### Added * Ability to assign multiple allocations at once when creating a new server. diff --git a/app/Observers/ServerObserver.php b/app/Observers/ServerObserver.php index 5b746a7b6..973b276d2 100644 --- a/app/Observers/ServerObserver.php +++ b/app/Observers/ServerObserver.php @@ -142,8 +142,10 @@ class ServerObserver public function updated(Server $server) { // Clear Caches - Cache::forget('Server.byUuid.' . $server->uuid . Auth::user()->uuid); - Cache::forget('Server.byUuid.' . $server->uuidShort . Auth::user()->uuid); + if (Auth::user()) { + Cache::forget('Server.byUuid.' . $server->uuid . Auth::user()->uuid); + Cache::forget('Server.byUuid.' . $server->uuidShort . Auth::user()->uuid); + } event(new Events\Server\Updated($server)); }