Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate route names caused error on route caching #77

Closed
yohanesgultom opened this issue Sep 25, 2021 · 3 comments
Closed

Duplicate route names caused error on route caching #77

yohanesgultom opened this issue Sep 25, 2021 · 3 comments
Assignees
Labels

Comments

@yohanesgultom
Copy link

Issue description

Duplicate route names caused error on route caching

silsilah/routes/web.php

Lines 19 to 20 in 01524cd

Route::get('password/change', 'Auth\ChangePasswordController@show')->name('password.change');
Route::post('password/change', 'Auth\ChangePasswordController@update')->name('password.change');

Steps to reproduce the issue

  1. Setup new instance from master branch
  2. Run command php artisan route:cache

What's the expected result?

Command successful without any error

What's the actual result?

Command failed with error below:

Command failed with error `Unable to prepare route [password/change] for serialization. Another route has already been assigned name [password.change].`

Additional details / screenshot

This can be easily fixed by renaming one of the route. But to ensure consistent naming convention, I think it's best left to the original author

@nafiesl nafiesl added the bug label Sep 25, 2021
@nafiesl
Copy link
Owner

nafiesl commented Sep 25, 2021

Hello, @yohanesgultom thanks for reporting.

I can reproduce the issue from my localhost.

$ php artisan route:cache
Route cache cleared!

In AbstractRouteCollection.php line 217:
                                                                                                                                
  Unable to prepare route [password/change] for serialization. Another route has already been assigned name [password.change].

Root cause:
As mentioned above, the route names are identical.

Workaround:

  • Need to change the named route for changing the password
  • Update all references to this route name (controller and views).

I will work on it, this should be quick. Thanks, @yohanesgultom.

@nafiesl nafiesl self-assigned this Sep 25, 2021
@nafiesl
Copy link
Owner

nafiesl commented Sep 25, 2021

Hi, @yohanesgultom this commit should fix the issue 8afb010. You can now try to pull the latest changes on the master branch, then try to run the route:cache command again.

We can expect this result on the terminal:

$ php artisan route:cache
Route cache cleared!
Routes cached successfully!

Thanks.

@yohanesgultom
Copy link
Author

@nafiesl it's working now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants