Closed (fixed)
Project:
JSON:API
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
31 Jan 2019 at 00:45 UTC
Updated:
15 Feb 2019 at 21:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
effulgentsia commentedCome to think of it, do we need this compiler pass at all? The PHPDoc for it says:
Except it now does, ever since #2923779-15: Normalizers violate NormalizerInterface. So why do we still add a
api_jsonencoder to the'serializer'service?Comment #3
wim leersSomething must have changed then, because that definitely used to be fixed :( Or maybe we missed something! But making sure it doesn't show up in Views was of course a key goal of that issue.
I reproduced the problem.
That's also explicitly documented in #2841027: JSON API format should only be used on JSON API routes, but can currently also be used for REST resources, which introduced that class.
That is a great point! #2923779: Normalizers violate NormalizerInterface indeed introduced our own
serializerservice. That means that most of the measures introduced in #2841027 are now obsolete.Because
\Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber::renderResponseBody()still doesHowever, we can factor that away, by just using the core
serializationmodule'sjsonencoder.Then we run into one last blocker: JSON:API's subclass of
serialization's JSON encoder does one extra thing. We can just move that intoResourceResponseSubscriber.Let's see if this passes all tests.
Comment #5
wim leersOne CS violation is masking a lot of failures. I can fix those failures, but the changes to fix those failures do show why we had that encoder still around.
I'll be the first to admit that this is where JSON:API module's internals are ugly and confusing. But don't forget we had to do this as well as #2923779: Normalizers violate NormalizerInterface precisely because of architectural flaws in Symfony's Serialization component… 😔
Comment #7
wim leersSorry for the noise — I'm migrating to a new computer while working on this.
Comment #8
effulgentsia commentedHow about this approach instead?
Different approach than #5 / #7, so the interdiff is relative to #3.
Comment #10
effulgentsia commentedComment #11
wim leersFewer changes. I like it more than my proposal :)
RTBC, but I'd like at least one of my two fellow maintainers to also +1 before committing.
Comment #12
wim leersThe title doesn't make it clear why this is considered a bug.
Comment #13
gabesulliceJust had one nit. If tests pass, I think this can go in.
I don't think we need the priority any more then.
Comment #14
effulgentsia commentedHere's a test for it. The -test-only patch is also the interdiff.
Comment #16
effulgentsia commentedhttps://dispatcher.drupalci.org/job/drupal8_contrib_patches/47662/ shows the test failure in the test-only patch.
The PHPCS error was:
Since module dependencies are automatically installed, here's one way to fix it :)
Comment #17
effulgentsia commentedComment #19
gabesulliceWFM! Thanks for adding a tests :)
Comment #20
wim leers👌