-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add CLI check to RouteCollection #2022
Conversation
CodeIgniter.php sets the request method on `request` or `clirequest` service, so RouteCollection needs to check the proper service to get the correct HTTPVerb to account for CLI, spoofing, and standard scenarios. See codeigniter4#2021
I think a slightly better fix here is to either pass in the request instance either through the constructor or through a setter method. That removes the dependency creation back to CodeIgniter.php, where it already knows which type of request it is. |
That's a good idea! I'm out for a few days but I'll take a look when I get a chance. Glad for anyone else to hop in before then. |
Looking at this, get/set HTTPVerb and the Do we get rid of |
One more place for HTTPVerb, called from Router but extraneous as it is simply injecting what is loaded by default:
|
@MGatner I've got this about wrapped up, actually. Just have one more test I have to fix up. It was a bigger change than expected. Due to the way routeCollection is used I didn't want to force a new call within route files to that, so I added it as a dependency to the Router class, which then sets the HTTPVerb on the RouteCollection itself. |
Oh great! Thanks for addressing it - I look forward to seeing your solution. Any thoughts on testing (re: my original comment "FWIW...")? |
Description
CodeIgniter.php sets the request method on
request
orclirequest
service, so RouteCollection needs to check the proper service to get the correct HTTPVerb to account for CLI, spoofing, and standard scenarios.See #2021
FWIW I believe the reason this wasn't caught is that all the request & routing clauses in
CodeIgniter.php
have conditional! (ENVIRONMENT === 'testing')
to be able to simulate non-CLI requests from CLI. There should probably be a test that spoofs its own environment (if possible) just to check forspark
integrity.Checklist: