Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
rest.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Feb 2016 at 04:51 UTC
Updated:
25 Feb 2016 at 14:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
neclimdulA test case that illustrate the bug, some extra tests that do some more unity tests(we only have web tests for this functionality) and a possible fix.
Comment #5
neclimdul*grumble* missing @group. phpunit runner runs fine without it.
Comment #7
wim leersWhat happens in the "else" case?
AFAICT there's no "else" case. If so, then why indent all this code, why not just add this extra condition in the original if-test?
.
Extraneous
\n.Useless comment?
s/Setup stubbed out/Stub/
Why exactly does it return NULL?
Also, "returns null" sounds weird, why not say "$response is NULL" this time, and use strict equality?
Comment #8
neclimdul1) Yeah, I started doing that first. First, the else is we fall through to returning the response unmodified. Second, I didn't realize this but this is not valid:
$data isn't defined in the is_scalar check.
That said, I missed a case where technically scalars need to be serialized So I think the right thing to do is serialize everything. The documentation for ResourceResponse::getResponseData()'s return is "Response data that should be serialized."
2-6) fixed. (3. man some habits die hard. the first Drupal module I worked on required these and they sneak in from time to time)
Related to #1, lots more test cases exposed through a provider in this patch. Test only again just to confirm we're still catching the failure after I consolidated the test.
edited for clarity.
Comment #10
neclimdullets try that patch again.
Comment #11
wim leersThe comment no longer makes sense now. Let's omit the ? Or, actually, let's remove that entire comment now, because it's no longer necessary?
directly?
Now it's much clearer what this tests: it simply tests that whatever is passed in is also what comes out. That makes a lot of sense :)
:)
s/TODO/@todo/
Comment #13
neclimdul1) sure, serialization isn't even the only thing going on in that block so it was misleading anyway. The check is clear and the code inside the if is well documented (or equally clear) so lets just remove it.
2) dangit
3) 4) :-D
5) thanks.
Comment #14
wim leersComment #16
catchCommitted/pushed to 8.1.x, thanks!
This looks like it would probably be fine for a patch release too, so re-open if you particularly want to see it in 8.0.x
Comment #17
neclimdulI'd like to see it. Currently rest plugins will need to do copy the serialization logic if they return a list of data that has the possibility of ever being empty. Which with permissions and filtering could even catch someone not expecting it.
Comment #18
neclimdulNot sure how to just re-run #13 against 8.0 So re-uploading #13 for testbot clarity. applied cleanly though so should be cherry-pickable.
Comment #19
wim leersComment #20
alexpottI agree there shouldn't be any harm in cherry picking this for 8.0.x. Committed f32314a and pushed to 8.0.x. Thanks!