diff --git a/src/Illuminate/Routing/SortedMiddleware.php b/src/Illuminate/Routing/SortedMiddleware.php index 1e3cf797a2c4..ec881c3d77ba 100644 --- a/src/Illuminate/Routing/SortedMiddleware.php +++ b/src/Illuminate/Routing/SortedMiddleware.php @@ -65,7 +65,7 @@ protected function sortMiddleware($priorityMap, $middlewares) } } - return $middlewares; + return array_values(array_unique($middlewares, SORT_REGULAR)); } /** diff --git a/tests/Routing/RoutingSortedMiddlewareTest.php b/tests/Routing/RoutingSortedMiddlewareTest.php index 4f3d74655899..baa84c8176f0 100644 --- a/tests/Routing/RoutingSortedMiddlewareTest.php +++ b/tests/Routing/RoutingSortedMiddlewareTest.php @@ -18,8 +18,7 @@ public function testMiddlewareCanBeSortedByPriority() 'Something', 'Something', 'Second', - 'Something', - 'Something', + 'Otherthing', 'First:api', 'Third:foo', 'First:foo,bar', @@ -28,16 +27,11 @@ public function testMiddlewareCanBeSortedByPriority() ]; $expected = [ - 'Something', - 'Something', - 'Something', 'Something', 'First:api', 'First:foo,bar', 'Second', - 'Something', - 'Something', - 'Second', + 'Otherthing', 'Third:foo', 'Third', ];