From 47e5f7646d2616389865b7c72a4f7de57953a8fd Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Thu, 14 Nov 2024 18:17:48 +0000 Subject: [PATCH] Fix issue where overwriting middleware variable when setting middleware priority (#53504) --- .../Foundation/Configuration/ApplicationBuilder.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index dde1af231d43..41bcd8b5054a 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -271,14 +271,14 @@ public function withMiddleware(?callable $callback = null) } if ($priorityAppends = $middleware->getMiddlewarePriorityAppends()) { - foreach ($priorityAppends as $middleware => $after) { - $kernel->addToMiddlewarePriorityAfter($after, $middleware); + foreach ($priorityAppends as $newMiddleware => $after) { + $kernel->addToMiddlewarePriorityAfter($after, $newMiddleware); } } if ($priorityPrepends = $middleware->getMiddlewarePriorityPrepends()) { - foreach ($priorityPrepends as $middleware => $before) { - $kernel->addToMiddlewarePriorityBefore($before, $middleware); + foreach ($priorityPrepends as $newMiddleware => $before) { + $kernel->addToMiddlewarePriorityBefore($before, $newMiddleware); } } });