framework: Route generation broken
- Laravel Version: 9.17.0
- PHP Version: 8.1.0
- Database Driver & Version: MySQL 8.0
Description:
When updating to Laravel > 9.13 route generation breaks. I tested with 9.14, 9.15, 9.16 and 9.17. I think the bug got introduced by #42425
Steps To Reproduce:
Route in web.php:
Route::group([
'prefix' => 'extranet',
'as' => 'extranet.',
'middleware' => 'auth',
], function () {
Route::get('gallery/{folder:slug}/albums', [GalleryFolderAlbumsController::class, 'index'])->name('gallery-folders.albums.index');
});
Laravel v9.13 (correct behaviour):
dd(route('extranet.gallery-folders.albums.index', $folder)); // -> http://localhost/de/extranet/gallery/aut-neque-dicta-qui-possimus-porro-sit-vel-iusto-voluptatem-quia-ut-excepturi-quaerat-labore-nobis-nesciunt-id-alias-voluptas-voluptatem/albums
Laravel v9.17 (wrong behaviour):
dd(route('extranet.gallery-folders.albums.index', $folder)); // -> http://localhost/de/extranet/gallery/1/albums
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (19 by maintainers)
The only thing that needs to be reset in that case is the
bindingFieldFor
method of theRoute
class. I did already revert all the other changes in one of the follow-up PRs. Just as a heads up, the test case for the bug that I initially tried to solve in #42425 will start failing. The test case that reproduces this ticket would look like thisHey @driesvints I was able to reproduce the issue in this repo:
https://github.com/mateusjunges/laravel-bug-report-42707
Steps to run the project:
php artisan migrate --seed
php artisan serve
http://localhost:8000
I can reproduce it using laravel v9.18.0, but when using the code from 9.x it is already solved and the URL is generated as expected.
Hope it helps
I found that it works in a fresh installation, but I found out that the problem only occurs when
URL::defaults(...)
is used (Test Examples both from fresh installation):Output of the failing test: