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

fix: when running on CLI, two Request objects were used in the system #6089

Merged
merged 10 commits into from
Jun 26, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Jun 7, 2022

Description
Fixes #6086

The current implementation has two Request objects (IncommingRequest and CLIRequest) when running on CLI.
Because some classes call Services::request() inside and it always returns IncommingRequest.

When CLIRequest is used in CodeIgniter, developers assume that the CLIRequest object is used system-wide.
This PR makes that so.

Checklist:

@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them breaking change Pull requests that may break existing functionalities labels Jun 7, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

I want to think about this one a bit. On the one hand it is convenient (from a developer standpoint) to have the appropriate Request class anytime the service is called; on the other hand it complicates (from a coding standpoint) our PSR-15 layer even more.

@kenjis
Copy link
Member Author

kenjis commented Jun 7, 2022

Yes, we need to consider this.

@kenjis
Copy link
Member Author

kenjis commented Jun 23, 2022

Changed the implementation a bit.

system/Config/Services.php Outdated Show resolved Hide resolved
@MGatner
Copy link
Member

MGatner commented Jun 23, 2022

I'm coming around to this. It is a bit hacky, but our current Request implementation is a mess so that might just need to be the case.

Let's see if we can get any more reviews and I'll keep chewing on it.

@kenjis
Copy link
Member Author

kenjis commented Jun 23, 2022

I've been thinking about it for a while and can't think of any other way to fix it except this way in the current situation.
Any idea is welcome.

@MGatner
Copy link
Member

MGatner commented Jun 24, 2022

If you've given this plenty of thought I don't feel the need to. At this point pretty much anything would be an improvement and what you've done looks reasonable to me.

@kenjis kenjis requested a review from samsonasik June 24, 2022 10:36
@kenjis
Copy link
Member Author

kenjis commented Jun 26, 2022

Added changelog.

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

Tiny syntax changes then I'm good with this.

user_guide_src/source/changelogs/v4.2.2.rst Outdated Show resolved Hide resolved
user_guide_src/source/changelogs/v4.2.2.rst Outdated Show resolved Hide resolved
Co-authored-by: MGatner <mgatner@icloud.com>
Co-authored-by: MGatner <mgatner@icloud.com>
@kenjis kenjis merged commit 8a70700 into codeigniter4:develop Jun 26, 2022
@kenjis kenjis deleted the fix-4.2-cli-filter-bug branch June 26, 2022 23:39
@kenjis kenjis mentioned this pull request Aug 27, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Pull requests that may break existing functionalities bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: CI 4.2.0 - running CLI command with csrf enabled causes error
3 participants