From 07d6df6b11cc6013be51d9a776a2a612c09e5aa0 Mon Sep 17 00:00:00 2001 From: Rias Date: Sat, 4 May 2024 15:51:16 +0200 Subject: [PATCH] Don't create entry redirects if the entry isn't published --- src/Listeners/CacheOldUri.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Listeners/CacheOldUri.php b/src/Listeners/CacheOldUri.php index 69f8414..86f833c 100644 --- a/src/Listeners/CacheOldUri.php +++ b/src/Listeners/CacheOldUri.php @@ -14,9 +14,9 @@ public function handle(EntrySaving $entrySaving) if (! config('statamic.redirect.enable', true)) { return; } - + $id = $entrySaving->entry->id(); - + Blink::forget('eloquent-entry-'.$id); $entry = Entry::find($id); @@ -24,6 +24,10 @@ public function handle(EntrySaving $entrySaving) return; } + if (! $entry->published()) { + return; + } + Cache::put('redirect-entry-uri-before', $uri); } }