Skip to content

route:cache with duplicate routes throws wrong exception #7452

@minorgod

Description

@minorgod

I stumbled upon this weird behavior when testing route caching. If I have a routes file containing only the following routes:

Route::get('home', 'WelcomeController@index');
Route::get('home', 'HomeController@index');

Running artisan route:cache throws exception:
exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in ..\vendor\laravel\framework\src\Illuminate\Foundation\Console\RouteCacheCommand.php:95

After carefully inspecting the RouteCollection passed to the buildRouteCacheFile() function in the RouteCacheCommand.php, I see no indication that there are any closures in the collection.

I realize it's silly to define the 'home' route twice pointing to different controllers, but it seems like the wrong exception is being thrown in the above case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions