Closed (duplicate)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Jul 2016 at 09:21 UTC
Updated:
21 Mar 2018 at 16:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dagmarComment #3
e0ipsoAwesome. Thanks for taking the time to contribute to the issue queue.
We shall see how the issue moves forward in core.
Comment #4
e0ipsoComment #5
e0ipsoComment #6
dagmarSome updates on this topic. I tested #2626924-36: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata which makes core REST functionality work (it returns the text with the right format).
But JSONAPI should apply the same Normalizer which is not automatically done. I could help to do this with some advice's of the recomended approach from you @e0ipso.
Comment #7
e0ipso@dagmar the normalizer will always depend on the response format.
Can you share what the JSON response is with the patch in #2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata applied?
Comment #8
dagmarIs the same with and without the patch. Only shows the raw value of the field.
I did some research and the reason why the core patch is not working is because it acts over https://api.drupal.org/api/drupal/core!modules!serialization!src!Normalizer!ComplexDataNormalizer.php/class/ComplexDataNormalizer/8.2.x and JSONAPI is not using that normalizer.
So to fix this we can either:
1) Inherit from ComplexDataNormalizer
or
2) Re-implement the check_markup directly on FieldItemNormalizer::normalize.
Option 1 seems the best approach, option 2 is faster and with less code changes.
Independently of the selected approach, we need this now: #2792389: [BUGFIX] Error handler makes impossible fix #2775205
Comment #9
dagmarThis is an example of a rudimentary approach to achieve (2).
Comment #10
dagmarFixed a typo.
Comment #12
e0ipsoKicking the tests (I'll move back to needs work afterwards).
I like this approach #2 enough to proceed with it. We will need a test for it though.
Thanks for taking care of this!
Comment #13
e0ipsoComment #18
dagmarPatch #10 included the patch from #2792389: [BUGFIX] Error handler makes impossible fix #2775205
Here is the new version.
Comment #19
e0ipsoDo we need to check if this value is set? I can't remember if there is a default.
Apart from that this is pretty much good to go, except for adding a test.
Comment #20
dagmarWhere should I place those tests?
Comment #21
e0ipsoMaybe you can add a new field to the Kernel tests.
Also, can you explore a non procedural alternative to check_plain?
Comment #22
dagmarThanks.
Well I did it. In my opionion this implies the approach 1 mentioned in #8.
The non procedural approach to replace check_markup implies the use of Typed Data API which is already implemented the REST approach taken in core.
Comment #23
e0ipsoThe core issue is getting closer.
Comment #24
dagmarSince #2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata changed a lot the last 2 months, I'm changing the focus of this issue to discuss how to implement the approach taken by core.
Comment #25
e0ipsoShould JSON API just focus on the data and rely on other web services to do data transformations: like converting markdown into HTML, applying text filters, …?
Comment #26
dagmarWhy would you do that? Is there any others examples of modules doing that?
Comment #27
e0ipsoI'm not sure what you mean by "that".
Comment #28
dagmarSorry, I mean. If core with #2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata is exposing the processed value a property. Why jsonapi would not expose that data attribute too?
Comment #29
e0ipsoIf core exposes that as a data attribute, there is no reason not to expose it. However, I am not clear what is the point of this issue. I would assume that when core exposes it, it will be directly serialized in the JSON API payload.
If that is true, then we can close this issue.
Comment #30
dagmarmakes sense @e0ipso. Please take a look to #8. I think there is some work to do in order to get the same data.
Comment #31
e0ipsoComment #32
dabito commentedI updated the patch for the current version of JSON API
Comment #33
e0ipsoBlocking this because of #2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata.
Comment #34
e0ipsoIn any case, we will need tests for this as well when the core issue is merged and we can just use that feature.
Comment #35
e0ipsoThis is fixed. Thanks all!
Comment #37
wim leersWait what, how did this go from being blocked to a commit (http://cgit.drupalcode.org/jsonapi/commit/?id=8dcb027), that doesn't even mention #2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata as a
@todo? Why did we commit code to the genericFieldItemNormalizerthat is actually highly specific to a single field type?Also, the code that was committed is severely broken, it's missing cacheability metadata for the processed text!
I think http://cgit.drupalcode.org/jsonapi/commit/?id=8dcb027 needs to be reverted.
Comment #38
dagmarI agree with @Wim Leers here. This was a tentative solution. Make it part of the module can lead to confusion this was fixed.
Comment #39
e0ipsoI'm good reverting this, I also think that we may want to be proactive and try to pull thing forward instead of pushing from behind.
Reverting.
Comment #41
wim leersMarked #2919996: Process formatted text fields before output as a duplicate with the following comment:
Comment #42
wim leersNote that since #2626924-166: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata (3 weeks ago), #2626924 has been moving forward again, because all blockers were fixed.
And since #2626924-204: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata (2 weeks ago) it has literally been blocked on reviews.
To the 8 followers of this issue: please help review that one! Once that's committed, this will automatically be fixed in JSON API too! And I solemnly pledge to backport it to JSON API sites running on Drupal 8.4, to ensure a smooth update path, and to ensure you can don't have to wait for Drupal 8.5 to be released in a few months!
Comment #43
larowlan#2626924: Include processed text in normalizations: "text" field type's "processed" computed property should be non-internal and carry cacheability metadata is in, which I think makes this no longer postponed?
Comment #44
e0ipsoThat's great news! Thanks for the update @larowlan.
Comment #45
wim leersComment #46
wim leersThere's no longer anything to do here: once #2921257: On Drupal 8.5, JSON API should respect Typed Data's new ::isInternal(), and JSON API Extras should use ::setInternal() lands, this issue will be solved as well! Keeping it around for now though, to consider backporting this inside JSON API for Drupal 8.4 sites.
And since #2921257 is itself postponed on another issue, marking this
PP-2.Comment #47
wim leers#2921257: On Drupal 8.5, JSON API should respect Typed Data's new ::isInternal(), and JSON API Extras should use ::setInternal() was completed some time ago 🎉