-
Notifications
You must be signed in to change notification settings - Fork 89
RESTful: Handle single field request with empty value #251
base: master
Are you sure you want to change the base?
Conversation
To keep BC we need to process as follows: - `foo=` -> `['foo' => '']` - `foo` -> `foo` - `foo&bar` -> `['foo' => '', 'bar' => '']` This is no longer dependent on content-type provided, as it was before.
@@ -100,22 +100,6 @@ public function testDispatchInvokesCreateMethodWhenNoActionPresentAndPostInvoked | |||
$this->assertEquals('create', $this->routeMatch->getParam('action')); | |||
} | |||
|
|||
public function testCanReceiveStringAsRequestContent() |
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.
This test has been merged into the new test added below.
@autowp I've made the change a bit more generic. It does not depend now on the content-type, as it was before. In case we have one element with empty value we are checking if the last character of the content is In general I think it should be completely changed to work properly with the given content type correctly, as now this is quite hacky, imo. |
This repository has been closed and moved to laminas/laminas-mvc; a new issue has been opened at laminas/laminas-mvc#18. |
This repository has been moved to laminas/laminas-mvc. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
Controller/AbstractRestfulController
There is no way to PUT/PATCH object with single field to empty value.
Request payload is interpreted as string (
$data = 'name=';
) regardless Content-Type.Proper value is
$data = ['name' => ''];
I think ideally is split behaviour by Content-Type but that follows to huge BC. (see testCanReceiveStringAsRequestContent)
My pull request handle just one situation (example above) by header.