Skip to content

Bug: Routing groups and in-group routes use filters that are only effective within the group. #9063

@fxnetw

Description

@fxnetw

PHP Version

8.1

CodeIgniter4 Version

4.5.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MySQL 5.7

What happened?

When I use a route group filter, and then use the filter on the routes within the route group, it only takes effect on the filters within the group.

Steps to Reproduce

//Routers

$routes->group('',['filter'=>['auth']],function($routes){
    $routes->get('getuserinfo','Mmeber::getUserInfo',['filter'=>['throttle']]);
});

Use filter:check output:

+--------+--------------+------------------------------------------+----------------------------------------+
| Method | Route        | Before Filters                           | After Filters                          |
+--------+--------------+------------------------------------------+----------------------------------------+
| GET    | /getuserinfo | forcehttps pagecache csrf token throttle | throttle pagecache performance toolbar |
+--------+--------------+------------------------------------------+----------------------------------------+

The csrf,token is globals filter,I think the filter execution order should be from the route group to the route within the group.For example:csrf->token->auth->throttle.But it does not include the route group filter.

Expected Output

I want the filter to include the route group filter.

The above content is translated by Google, so there may be some errors, but I hope this error can be fixed.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions