Skip to content

Bug: There are cases where the name of a named route is not determined. #8039

@tomomo

Description

@tomomo

PHP Version

8.2

CodeIgniter4 Version

4.4.1

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

apache

Database

No response

What happened?

There are cases where the name of a named route is not determined.
Unnamed or duplicate.

# app/Config/Routes.php
$routes->get('login', [AuthController::class, 'showLogin'], ['as' => 'loginShow']);
$routes->post('login', [AuthController::class, 'login'], ['as' => 'login']);
$routes->get('logout', [AuthController::class, 'logout'], ['as' => 'logout']);
php spark routes

CodeIgniter v4.4.1 Command Line Tool - Server Time: 2023-10-13 02:07:54 UTC+00:00

+--------+--------+-----------+--------------------------------------------+----------------+---------------+
| Method | Route  | Name      | Handler                                    | Before Filters | After Filters |
+--------+--------+-----------+--------------------------------------------+----------------+---------------+
| GET    | /      | »         | \App\Controllers\Home::index               |                | toolbar       |
| GET    | login  | loginShow | \App\Controllers\AuthController::showLogin |                | toolbar       |
| GET    | logout | »         | \App\Controllers\AuthController::logout    |                | toolbar       |
| POST   | login  | loginShow | \App\Controllers\AuthController::login     |                | toolbar       |
+--------+--------+-----------+--------------------------------------------+----------------+---------------+

"logout" cannot be named.
"login(GET or POST") has the same name.(Is this the specification?)

Steps to Reproduce

Add the following to app/Config/Routes.php

# app/Config/Routes.php
$routes->get('login', [AuthController::class, 'showLogin'], ['as' => 'loginShow']);
$routes->post('login', [AuthController::class, 'login'], ['as' => 'login']);
$routes->get('logout', [AuthController::class, 'logout'], ['as' => 'logout']);

Expected Output

Check with php spark routes etc.

php spark routes

CodeIgniter v4.4.1 Command Line Tool - Server Time: 2023-10-13 02:07:54 UTC+00:00

+--------+--------+-----------+--------------------------------------------+----------------+---------------+
| Method | Route  | Name      | Handler                                    | Before Filters | After Filters |
+--------+--------+-----------+--------------------------------------------+----------------+---------------+
| GET    | /      | »         | \App\Controllers\Home::index               |                | toolbar       |
| GET    | login  | loginShow | \App\Controllers\AuthController::showLogin |                | toolbar       |
| GET    | logout | »         | \App\Controllers\AuthController::logout    |                | toolbar       |
| POST   | login  | loginShow | \App\Controllers\AuthController::login     |                | toolbar       |
+--------+--------+-----------+--------------------------------------------+----------------+---------------+

"logout" cannot be named.
"login(GET or POST") has the same name.(Is this the specification?)

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