Framework: [7.x] Route caching STILL doubles URI prefixes for 2+ nesting levels

Created on 4 Mar 2020  路  4Comments  路  Source: laravel/framework

  • Laravel Version: 7.0.2
  • PHP Version: 7.4.3

Description:

Route caching system doubles route prefixes for routes that are grouped and prefixed with more than 2 levels of nesting.
It appeared in 7.0.1 and the new release fixed the problem for only 1 level of nesting.
But the problem persists for 2+ levels of nesting.

Steps To Reproduce:

  1. Add this routes group to your web router file.
    Route::prefix('profile')->group(function () { Route::prefix('{user:username}')->group(function () { Route::prefix('block')->middleware(['auth'])->group(function () { Route::post('/', 'HomeController@index')->name('profile.block'); Route::delete('/', 'HomeController@index')->name('profile.unblock'); }); }); });

Like this:
carbon (6)

  1. Cache the routes in the command line using:
    php artisan route:cache

  2. Now get the routes list from the command line using php artisan route:list, and you will see this route:

profile/{user:username}/block/profile/{user}/block

bug

All 4 comments

After a quick look, it seems like this bit of code is causing the problem:

image

The prefix contains the scoping parameters, in your case {user:username}, whereas the uri does not, so it's not getting replaced / removed from the URI.

up

Looking into this

Released 7.0.3 with a fix for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainSauvaire picture RomainSauvaire  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

PhiloNL picture PhiloNL  路  3Comments

progmars picture progmars  路  3Comments