Closed (fixed)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Jan 2018 at 13:15 UTC
Updated:
2 Apr 2018 at 16:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersComment #3
wim leers#2920536: Force all serializer encoders + normalizers services to be private landed in core. Would be great if we would mirror that behavior in JSON API.
Comment #4
wim leersThis ports the relevant changes from #2920536: Force all serializer encoders + normalizers services to be private. Even just this change is causing lots of fails because for example
JsonApiDocumentTopLevelNormalizerTestis retrieving the normalizer from the container.This does NOT yet mark the
jsonapi.serializer_do_not_use_removal_imminentservice itself as private.Comment #6
wim leersStill postponed on #2883086: [PP-1] Port RequestHandler + ResourceResponseSubscriber improvements from REST module to JSON API. Just wanted to post an initial patch.
Comment #7
wim leers@gabesullice pointed out that the problem here is that the
RequestHandlerneeds to get the serializer service. But that can be solved by injecting it. Attached interdiff fixes that, and makes all services be injected into the request handler.This should pass more tests.
Comment #8
gabesulliceWhat?! How did I never realize this syntax was possible before?!
XD
:O)
Nit: can we keep this near the top of the class?
Comment #9
wim leers#8 :)
#8.4: that's dead code… I should just remove it.
Comment #10
wim leersFix
RequestHandlerTest's mocks.Comment #12
wim leersFix remaining failures in
JsonApiDocumentTopLevelNormalizerTest.Comment #13
wim leers#12 was incomplete.
Comment #16
wim leersThe remaining failures were hard to debug. They happen because
\Drupal\jsonapi\Normalizer\RelationshipItemNormalizer::__construct()gets\Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizerinjected. But because it's injected,setSerializer()has not yet been called on it, which\Drupal\jsonapi\Serializer\Serializer::__construct()does.But we haven't changed any logic, so why is this happening?
Well, it's been happening since #4. #4 is marking all normalizer services private. Marking a service private also makes it non-shared. And it's impossible to mark it shared explicitly when it's marked private. So simply doing
setShared(TRUE)orshared: truedoesn't fix the problem.The real problem here is that
RelationshipItemNormalizeris doing something it shouldn't. And we even addedfor that in issue comment #2831185-5: Rename DocumentWrapper to JsonApiDocumentTopLevel and DocumentRootNormalizer to JsonApiDocumentTopLevelNormalizer (commit
b064a203) in Dec 2016. Fixing that is out of scope here, so just making sure that thesetSerializer()calls cascades.WHEW! That was a hard one to debug!
Comment #17
wim leersComment #18
wim leersGREEN! Green for the first time!
So now let's do the final step: mark the serializer service as private too.
Comment #19
wim leersYAY! ALSO GREEN!
Let's fix CS violations.
Comment #20
wim leersSelf-review:
Missing docs.
Needs better description.
Fixed both.
Comment #21
e0ipsoI love your self-reviews, they are so helpful when reviewing!
Comment #22
gabesullice❤️
<3
There is no public API for even the serializer.
<3
Comment #23
gabesulliceJust needs the one comment change.
Comment #24
wim leersFixed :)
Comment #25
wim leersAlso:
❤️
Comment #26
gabesulliceComment #27
wim leersThis was marked postponed/
[PP-1]in #6 by me:… but in fact I see no reason to block this on that. In fact, this issue makes #2883086 simpler! This patch makes zero functional changes to
RequestHandler. The only thing this changes, is how it gets the services it needs injected. #2883086 will change much more, and this makes that slightly easier.Removing the
[PP-1].Comment #28
wim leersComment #29
wim leersComment #30
wim leers🤐
Comment #31
wim leersThis now also blocks #2941685 and #2883086. See #2883086-33: [PP-1] Port RequestHandler + ResourceResponseSubscriber improvements from REST module to JSON API.
Comment #32
e0ipsoNifty!
I'm not a fan of using the serializer (that calls the normalizers) to kernel-test the normalizers. However I see the convenience of it and I support that.
💥
Comment #34
wim leersThis was accidental! Attached is a patch that fixes both places where that happened, and actually updates even one more pre-existing one!
Comment #35
wim leersThis also means #2945093: Comprehensive JSON API integration test coverage phase 3: test JSON API-specific use cases: related/relationship routes, includes and sparse field sets is now less blocked, as is #2883086: [PP-1] Port RequestHandler + ResourceResponseSubscriber improvements from REST module to JSON API! Hurray!
And it also means there's one less thing to do for #2931785: The path for JSON API to core :)
Comment #37
e0ipsoCommitted! Thanks again. You rock, I will not get tired of telling you both.
Comment #38
wim leers❤️