Skip to content

Commit 5d59d36

Browse files
committed
Fixes bug preventing proper updating of caches and models due to undefined Auth::user()
1 parent e688468 commit 5d59d36

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1111

1212
### Fixed
1313
* 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.
14+
* `[pre.4]` — Fixes bug preventing server updates from occurring by the system due to undefined `Auth::user()` in the event listener.
1415

1516
### Added
1617
* Ability to assign multiple allocations at once when creating a new server.

app/Observers/ServerObserver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ public function updating(Server $server)
142142
public function updated(Server $server)
143143
{
144144
// Clear Caches
145-
Cache::forget('Server.byUuid.' . $server->uuid . Auth::user()->uuid);
146-
Cache::forget('Server.byUuid.' . $server->uuidShort . Auth::user()->uuid);
145+
if (Auth::user()) {
146+
Cache::forget('Server.byUuid.' . $server->uuid . Auth::user()->uuid);
147+
Cache::forget('Server.byUuid.' . $server->uuidShort . Auth::user()->uuid);
148+
}
147149

148150
event(new Events\Server\Updated($server));
149151
}

0 commit comments

Comments
 (0)