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

fix: routes registration bug #6644

Merged
merged 5 commits into from
Oct 9, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 7, 2022

Description
If there are two routes having the same from but with the different name,
the first route is not registered correctly.

  • fix RouteCollection
  • fix incorrect tests

How to Reproduce the Bug

$routes->get('/', static fn () => 'Hello World!', ['as' => 'RouteName']);
$routes->get('/', 'Home::index');

Before:

+--------+--------+------------------------------------------+----------------+---------------+
| Method | Route  | Handler                                  | Before Filters | After Filters |
+--------+--------+------------------------------------------+----------------+---------------+
| GET    | /      | \App\Controllers\Home::index             |                | toolbar       |
| CLI    | ci(.*) | \CodeIgniter\CLI\CommandRunner::index/$1 |                |               |
+--------+--------+------------------------------------------+----------------+---------------+

After:

+--------+--------+------------------------------------------+----------------+---------------+
| Method | Route  | Handler                                  | Before Filters | After Filters |
+--------+--------+------------------------------------------+----------------+---------------+
| GET    | /      | (Closure)                                |                | toolbar       |
| CLI    | ci(.*) | \CodeIgniter\CLI\CommandRunner::index/$1 |                |               |
+--------+--------+------------------------------------------+----------------+---------------+

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

kenjis added 3 commits October 7, 2022 14:53
$routes and $routesOptions are not the same structure.
$routesOptions don't have route names.
If there are two routes having the same `from` but not the same name,
the route and the option were not connected correctly.
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 7, 2022
@kenjis kenjis changed the title fix: routes processing bug fix: routes registration bug Oct 7, 2022
kenjis added 2 commits October 7, 2022 15:24
The second call for add `exampleRoute` would be ignored.
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to come back to this one

@kenjis kenjis merged commit 9f42e31 into codeigniter4:develop Oct 9, 2022
@kenjis kenjis deleted the fix-routes-processing branch October 9, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants