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: auto routes incorrectly display route filters with GET method #5712

Merged
merged 2 commits into from
Feb 21, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Feb 20, 2022

Description
Follow-up #5628

  • auto routes incorrectly display route filters with GET method
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -31,7 +31,7 @@ $routes->setAutoRoute(true);
 
 // We get a performance increase by specifying the default
 // route since we don't have to scan directories.
-$routes->get('/', 'Home::index');
+$routes->get('/', 'Home::index', ['filter' => 'csrf'] );
 
 /*
  * --------------------------------------------------------------------

Before:

+--------+------------------+------------------------------------------+----------------+---------------+
| Method | Route            | Handler                                  | Before Filters | After Filters |
+--------+------------------+------------------------------------------+----------------+---------------+
| GET    | /                | \App\Controllers\Home::index             | csrf           | csrf toolbar  |
| CLI    | ci(.*)           | \CodeIgniter\CLI\CommandRunner::index/$1 |                |               |
| auto   | /                | \App\Controllers\Home::index             | csrf           | csrf toolbar  |
| auto   | home             | \App\Controllers\Home::index             |                | toolbar       |
| auto   | home/index[/...] | \App\Controllers\Home::index             |                | toolbar       |
+--------+------------------+------------------------------------------+----------------+---------------+
  • The auto route / does not reach when GET.
  • It can be accessible when POST/PUT/..., but it has no filters actually.

After:

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

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 kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 20, 2022
@kenjis kenjis merged commit 77c5ba9 into codeigniter4:develop Feb 21, 2022
@kenjis kenjis deleted the fix-spark-routes branch February 21, 2022 08:30
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.

2 participants