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

Bug: Routing group filter not working on nested or complex routes #2390

Closed
Spreizu opened this issue Nov 7, 2019 · 3 comments
Closed

Bug: Routing group filter not working on nested or complex routes #2390

Spreizu opened this issue Nov 7, 2019 · 3 comments

Comments

@Spreizu
Copy link

Spreizu commented Nov 7, 2019

Example routes, where filter is not being applied:

Nested:
$routes->group('{locale}', function($routes) { $routes->group('admin', ['filter' => 'require-admin'], function($routes) { $routes->get('/', 'AdminDashboard::index'); }); });

Not nested, but more complex group:
$routes->group('en/admin', ['filter' => 'require-admin'], function($routes) { $routes->get('/', 'AdminDashboard::index'); });

If group is simple (containing only admin), then filter is working.

@aretan
Copy link

aretan commented Nov 10, 2019

Me too:

GET /api/v1/first/100/second

404 - File Not Found
Controller method is not found: 100
$routes->group('api/v1', ['namespace' => 'App\API\v1'], function($routes)
{
    $routes->group('first/(:any)', ['namespace' => 'App\API\v1'], function($routes)
    {
        $routes->resource('second');
    });
    $routes->resource('first');
});
$ php ./vendor/codeigniter4/framework/spark routes


CodeIgniter CLI Tool - Version 4.0.0-rc.3 - Server-Time: 2019-11-10 02:31:45am

+------------------------------------+--------+------------------------------------------------+
| Route                              | Method | Command                                        |
+------------------------------------+--------+------------------------------------------------+
| api/v1/first/(.*)/second           | get    | \App\API\v1\Second::index                      |
| api/v1/first/(.*)/second/new       | get    | \App\API\v1\Second::new                        |
| api/v1/first/(.*)/second/(.*)/edit | get    | \App\API\v1\Second::edit/$1                    |
| api/v1/first/(.*)/second/(.*)      | get    | \App\API\v1\Second::show/$1                    |
| api/v1/first                       | get    | \App\API\v1\First::index                       |
| api/v1/first/new                   | get    | \App\API\v1\First::new                         |
| api/v1/first/(.*)/edit             | get    | \App\API\v1\First::edit/$1                     |
| api/v1/first/(.*)                  | get    | \App\API\v1\First::show/$1                     |

@aretan
Copy link

aretan commented Nov 10, 2019

this problem can resolve by line:

$routes->setAutoRoute(false);

@Spreizu
Copy link
Author

Spreizu commented Nov 10, 2019

I have done further testing and can add, that this problem occurrs when {locale} is specified as group name. If, for example, I replace '{locale}' with 'test', then the filter is working.
Is believe this is a bug.

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

No branches or pull requests

3 participants