-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
!!!TASK: Remove deprecated Http objects and replace with PSR-7 implementation #1552
Conversation
OK, I totally missed this change and basically started the same in parallel. I will try to rebase my work on top of this, as I have a couple of changes that are not in here yet. We might want to discuss the Factories. I currently do not use them. |
Thanks for the feedback! Yes, let's discuss things. Just hit me on slack sometime this week. This is a pretty early status and I only got the first tests pass again as easily as possible, by jumping on the Request::create* stuff to avoid rewriting all those tests. This is not how it should be ofc. If you manage to rebase your work on this or merge them together, that would be awesome! |
There we go, tests will not run fully, but should be a step in the right direction. One thing to discuss is default SERVER vars as they know get applied with our request. That breaks a bunch of tests at the moment and I am not 100% sure how to fix this. Potentially could be fixed in the ServerRequestFactory but \o/ not sure In general I didn't use the factories because in the request handler we are bound to a specific implementation anyways. It's nice to have for other components though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback
@@ -32,6 +32,9 @@ class RequestBodyParsingComponent implements ComponentInterface | |||
public function handle(ComponentContext $componentContext) | |||
{ | |||
$httpRequest = $componentContext->getHttpRequest(); | |||
if (!empty($httpRequest->getParsedBody())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to check how we handled this before, but Guzzle ServerRequset::fromGlobals() sets $_POST as parsedBody, so if it was a "normal" POST request the parsed body will be fine already at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we just merged $_POST into arguments on Request creation and kept the request body around until we parsed it when mapping arguments for the ActionController. Guzzle is more correct in assigning the POST as parsed Body, if it exists. It's just a PHP inbuilt request body parsing for multipart/form-data
/application/x-www-form-urlencoded
after all (which apparently only works for POST requests but e.g. not PUT).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of feedback. Generally, this isn't as weird as I thought, but it brings up a couple of locations, where our current logic is lacking, because we end up invoking ->render()
and completely ignoring the return value.
Neos.Flow/Classes/Mvc/ActionResponseRenderer/IntoComponentContext.php
Outdated
Show resolved
Hide resolved
Neos.FluidAdaptor/Classes/Core/Widget/AbstractWidgetViewHelper.php
Outdated
Show resolved
Hide resolved
Neos.FluidAdaptor/Classes/Core/Widget/AbstractWidgetViewHelper.php
Outdated
Show resolved
Hide resolved
Neos.FluidAdaptor/Classes/ViewHelpers/Widget/AutocompleteViewHelper.php
Outdated
Show resolved
Hide resolved
Neos.FluidAdaptor/Classes/ViewHelpers/Widget/PaginateViewHelper.php
Outdated
Show resolved
Hide resolved
Neos.FluidAdaptor/Tests/Functional/Core/Fixtures/ViewHelpers/RedirectViewHelper.php
Outdated
Show resolved
Hide resolved
Alright, more tomorrow, I am done for today... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proxy review.
I restored the branch just in case.... with such a big change you never know... |
Previously the `Dispatcher` invoked the `startAuthentication()` method of all authenticated tokens. That behavior was changed by accident with neos#1552 and now only the first Entry Point was triggered.
Not to be confused with the psr requests interface. TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. _Initially_ the interface was introduced with neos@2a26925 at beginning of time. At that time this was done probably to be able to type against the interface instead of the abstract `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface neos@8c40ff2 and with the full separation of action and cli requests neos#1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. -------- _Initially_ the interface was introduced with 2a26925 at beginning of time. At that time this was done probably to be able to type against the interface instead of the common `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface 8c40ff2 and with the full separation of action and cli requests #1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. -------- _Initially_ the interface was introduced with 2a26925 at beginning of time. At that time this was done probably to be able to type against the interface instead of the common `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface 8c40ff2 and with the full separation of action and cli requests #1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. -------- _Initially_ the interface was introduced with 2a26925 at beginning of time. At that time this was done probably to be able to type against the interface instead of the common `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface 8c40ff2 and with the full separation of action and cli requests #1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. -------- _Initially_ the interface was introduced with neos/flow-development-collection@39b8f80 at beginning of time. At that time this was done probably to be able to type against the interface instead of the common `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface neos/flow-development-collection@8ab6a29 and with the full separation of action and cli requests neos/flow-development-collection#1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
TLTR: Since the separation of http and cli requests the interface is completely unused. And strict types against its only implementation, the ActionRequest make it impossible to implement a custom request. -------- _Initially_ the interface was introduced with neos/flow-development-collection@39b8f80 at beginning of time. At that time this was done probably to be able to type against the interface instead of the common `Request` class, that the Cli and Web Request both extended. With the removal of many methods in its interface neos/flow-development-collection@8ab6a29 and with the full separation of action and cli requests neos/flow-development-collection#1552 the interface became useless. The dispatcher and controller interface are both typed against the `ActionRequest` and so it's impossible to implement a custom request.
This replaces the HTTP stack of Flow with PSR-7.
Many areas of Flow are affected by this, most notably and breaking:
ActionRequest::getParentRequest()
will return null at the top instead of an HttpRequest, you can still get the HttpRequest viaActionRequest::getHttpRequest()
ActionRequest::fromHttpRequest(ServerRequestInterface $httpRequest)
introducedActionRequest::createSubRequest()
introducednew
\Neos\Flow\Mvc\ActionRequestFactory
introduced to correctly merge arguments from the HTTP requestNeos.Http.Factories
introduced, implementing PSR-17 HTTP factories, use those to create and fake HTTP requestsRelated: #658
Example API Changes:
Mvc\Response
, insteadActionRequest
andActionResponse
are the API inside the MVC stackActionRequest
, use theActionRequestFactory->createActionRequest($serverRequest, $arguments)
$this->response->setHeader('Content-Type', ...)
->$this->response->setContentType(...)
$this->response->setHeader('Location', ...)
->$this->response->setRedirectUri(...)
$this->response->setStatus(...)
->$this->response->setStatusCode(...)
$this->response->setHeader(...)
->$this->response->setComponentParameter(SetHeaderComponent::class, ...)
Request::create(...)
->new ServerRequest('GET', ...)
$httpRequest->getBaseUri()
->$httpRequest->getAttribute(ServerRequestAttributes::BASE_URI)