Skip to content

chore: remove IncomingRequest deprecations - #9851

Merged
michalsn merged 2 commits into
codeigniter4:4.7from
michalsn:chore/remove-incomingrequest-deprecations
Dec 21, 2025
Merged

chore: remove IncomingRequest deprecations#9851
michalsn merged 2 commits into
codeigniter4:4.7from
michalsn:chore/remove-incomingrequest-deprecations

Conversation

@michalsn

Copy link
Copy Markdown
Member

Description
This PR removes deprecated methods from the IncomingRequest class.

The deprecated $config parameter has been removed from setPath(), and the method visibility has been changed from public to private.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added refactor Pull requests that refactor code 4.7 labels Dec 20, 2025

@neznaika0 neznaika0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Working on deprecations is important as new features.

@michalsn
michalsn merged commit 23b64e6 into codeigniter4:4.7 Dec 21, 2025
50 checks passed
@michalsn

Copy link
Copy Markdown
Member Author

Thank you @neznaika0 and @paulbalandan!

@michalsn
michalsn deleted the chore/remove-incomingrequest-deprecations branch January 6, 2026 11:29
@cncoa

cncoa commented Sep 3, 2026

Copy link
Copy Markdown

My project has unfortunately been broken because of this change. What sort of work around is there?

We route by domain.com/{tenant}/dashboard/...

We used setPath on the incoming request to remove {tenant}/ and have the new auto routing work on everything after it.

With it being made private, the entire platform routing doesn't work. I can modify the path via reflection, but since it's not a maintained solution, I worry about the long term effects.

Any advice?

@michalsn

michalsn commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@cncoa I'm sorry this change affected your project. IncomingRequest::setPath() has been deprecated since v4.4.0, and its removal in v4.7.0 follows our deprecation policy.

A custom router may be a good fit for this use case. You can override Router::autoRoute() and remove the tenant segment only from the path passed to Auto Routing:

namespace App\Routing;

use CodeIgniter\Router\Router;

final class TenantRouter extends Router
{
    public function autoRoute(string $uri)
    {
        $segments  = explode('/', trim($uri, '/'), 2);
        $routePath = $segments[1] ?? '/';

        parent::autoRoute($routePath === '' ? '/' : $routePath);
    }
}

The custom router then needs to be registered as the router service in Config\Services.

This keeps the rest of the request unchanged and modifies only the path passed to Auto Routing. Explicit routes are still checked against the original URI before autoRoute() is called, and the original request URI remains available.

Tenant validation and resolution can be handled separately, for example in a filter using the first segment of the original URI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants