Skip to content

Bug: Route Filters Are Ignored When Using Custom Placeholders in Routing #9804

@frkiergn

Description

@frkiergn

PHP Version

8.3

CodeIgniter4 Version

4.6.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

apache

Database

No response

What happened?

When defining a custom placeholder in CodeIgniter 4 routing, the routes that use this placeholder do not execute the filters assigned to them. The framework seems to completely skip the filter layer for those routes.

Steps to Reproduce

  1. Create a custom placeholder in app/Config/Routes.php:

$routes->addPlaceholder('code', '[A-Z]{3}[0-9]+')

  1. Define a route using this placeholder and apply filters:

$routes->get('test/(:code)', 'TestController::index', ['filter' => 'auth']);

  1. Access a URL matching the pattern:

/test/ABC123

  1. Observe that the auth filter does not run.

  2. Check the defined filter from the listed routes using the php spark routes command.

| Method | Route | Name | Handler | Before Filters | After Filters  
| GET    | test/([A-Za-z]+-[A-Za-z0-9]+) | » | \App\Controllers\Test::index/$1 | <unknown>   | <unknown>  

Additional Notes

  • Filters work correctly when using standard placeholders.
  • The issue appears only when using custom placeholders created via addPlaceholder().

Expected Output

Filters defined for a route that uses a custom placeholder should run normally, the same way they run with the default placeholders ((:num), (:segment), etc.).

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