Problem/Motivation
Something changed between alpha26 and alpha27 related to entity reference revisions and schema.org mappings.
Entity reference revisions no longer map correctly. See screenshot.
It results in:
"recipeIngredient": [
"NODE TITLE IS HERE \u003E Ingredients"
],
"recipeInstructions": [
"NODE TITLE IS HERE \u003E Instructions"
],
My Ingredients and Instructions are Entity reference revisions of Reference type: Paragraph.
Steps to reproduce
On alpha27, set up a Paragraph (like Ingredients).
Then in your Recipe content type, create an Ingredients fields and use entity reference to the Ingredients paragraph.
Then using in the Scheme.org tab, map the recipeIngredients to the Ingredients paragraph.
This used to work perfectly on alpha26.
Using 10.3.10, PHP 8.3.12
Let me know if you need further info.
Issue fork schemadotorg-3489382
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jrockowitz commentedI am not sure sure I am able to reproduce your issues.
Below are my steps to reproduce..
What field type are you using? 'Paragraphs' or 'Entity reference revisions'
Comment #3
jrockowitz commentedI am pretty sure #3469251: Improve layout starter kit caused this regression.Comment #4
xamountI part that I cannot do is:
When I try to manually map recipeIngredient, I only get the choice of Entity reference revisions (there are no Paragraphs, ever for other Paragraphs). I only see Entity reference revisions for all the paragraphs. (see attached screenshot)
My Ingredients Paragraph looks like the 2nd screenshot.
In the Recipe content type, for the Ingredients field, it's:
Entity reference revisions
Reference type: Paragraph
Paragraph type: Ingredients
Just an fyi, my Recipe content type existed before I started using the Schema.org Blueprint module, so I did not create Recipe Schema.org type as in your second bullet point (although I don't think this has anything to do with it).
Comment #5
xamountForgot to attach the first screenshot to my last message.
Comment #6
jrockowitz commentedI think you are running into #3376124: Prepare for 10.2: Move preconfigured paragraph field type to general category, fix tests
The Paragraphs field has been moved to the 'General' category.
#3489462: Improve field type categorization. will return it to the 'References' category in the Schema.org Blueprints UI.
Comment #7
jrockowitz commentedI merged #3489462: Improve field type categorization.. I am almost certain that fixes the issue. Please reopen this ticket if I am wrong.
Comment #8
abhinand gokhala k commentedI have checked after applying patch ( #3489462: Improve field type categorization.) but still facing the same issue.
Before updating module

After updating module
the screenshot took from 'https://search.google.com/test/rich-results'
Comment #9
abhinand gokhala k commentedIngredients in a paragraph reference field.
Comment #10
jrockowitz commentedI don't know how you got the custom Ingredients paragraph type to automatically switch recipeIngredient to use the entity reference revision field.
My steps in attempting to reproduce
Comment #11
abhinand gokhala k commentedThere is a custom module for altering recipe ingredients, but before making the alterations, I have dumped the array.
Please review it.
In module version alpha26:

In module version alpha27:

Comment #12
jrockowitz commentedThe change via JSON-LD is most likely due to the addition of "Schema.org type entity references display" settings in /admin/config/schemadotorg/settings/jsonld.
@see #3481313: Track and prevent displayed entity reference recursions in JSON-LD
Comment #13
abhinand gokhala k commentedI have reproduced the issue in fresh Drupal 10 environment
Demo: Google Drive video Link
Steps to Reproduce:
textObjectin the schema:textObjectin the schema.Comment #14
abhinand gokhala k commentedComment #15
xamountUpdating priority as this blocks us from upgrading past alpha26. Let us know if you need any more details or in what way we can help.
Comment #16
jrockowitz commentedI am almost sure that the recommendation via #12 is correct, and you will need to adjust the "Schema.org type entity references display" settings (/admin/config/schemadotorg/settings/jsonld)
It takes a lot of time for someone to reproduce your specific example.
You might need a developer to debug your issue or write a hook to alter the JSON-LD to meet your requirements.
The module is still in alpha releases which means APIs and output can change,.
Comment #17
jrockowitz commentedI was able to reproduce the issue/regression, and it is a one-line fix.
I noticed that the Schema.org Blueprint Additional Mapping module validated the https://schema.org/recipeIngredient property, and https://schema.org/TextObject is an expected value. The Schema.org Blueprint Additional Mapping module removes unexpected types.
In other words, the generated Schema.org JSON-LD (see below) using https://schema.org/TextObject is not valid via https://validator.schema.org/ (see below)
Comment #19
xamountThanks a whole bunch for helping on this, I really appreciate it.
I've tested the patch from #18 on alpha27 and alpha29
On alpha27 and alpha29 - I get the same results which are:
- it works, but I need to clear the cache each time I visit a node page with the structured data. If I visit another node page, the fields that use paragraphs in the structured data are entirely missing. I then clear the cache and I can see it works upon a refresh. When I say it "works", I mean I can see all the structured data as it should be (like if I was viewing it on alpha26).
I thought this might be a local caching issue or something, but then I tried alpha26 (with no patch) and it works flawlessly without having to clear cache. So I don't think it's a local caching issue.
Comment #20
jrockowitz commentedYou definitely need to clear the entire cache.
Comment #22
jrockowitz commentedI merged the MR. If you see any more regressions, please update this ticket or open a new ticket.
Comment #23
xamountRe-opening as I was able to make some progress on this.
(Sorry but this is a tricky and challenging issue to resolve coupled with the fact that it was also during a holiday period)
I took a look at the code from line 61 to 96 of schemadotorg_jsonld.module
If I commented out that code and applied the patch and used alpha29, it works. "It works" means I can see the recipeIngredients (which comes from a paragraph) without having to refresh and clear cache multiple times)
So I think the bug lies somewhere between line 61-96. Something related to caching but I cannot figure it out.
Comment #24
jrockowitz commented@see #3497197: Ensure the variation cache is cleared for JSON-LD.
Comment #25
xamountI have made a little more progress on this.
I applied the patch from this issues queue and also #3497197: Ensure the variation cache is cleared for JSON-LD. and I am using alpha29. I am still getting this caching issue.
I took a deeper dive into the code.
This line of code in particular is causing the issue:
$data = $builder->build($route_match, $bubbleable_metadata);If I commented that line out and manually provided $data, then it works.
The key difference between my manual $data and the $data provided by the build function lies in the structure of the recipeIngredient and recipeInstructions properties. In the build function $data, these properties start with an indexed array, meaning they have an initial key of 0, whereas in my manual $data, these are directly embedded without an index.
Comment #26
jrockowitz commentedCan you please try fully clearing
your cache?
By restarting redis/memcache or manually clearing the cache tables in the database.
Comment #27
xamountI've tried clearing caches as you mentioned. Still getting this issue. Our site is not using memcache/redis.
Importantly, I can replicate this issue on the master site, dev site and also locally (using ddev). So I'm 99.9% sure it's not environment specific.
I'm wondering if this is a Drupal core issue..? I've looked at your BubbleableMetadata implementation. It seems ok, but I'm not an expert in using Bubblemetadata.
To me it seems the problem is coming from the build() function and using Bubblemetadata. My latest conclusion at this point is that it works when not using BubbleableMetadata (like in alpha26).
Comment #28
xamountI discovered that disabling Internal Page Cache resolves the issue. However, this is not a feasible long term solution.
Keep in mind, this issue only surfaced from alpha27 and going forward.
Comment #29
jrockowitz commentedCan we close this issue now that we have determined custom code was causing the caching issue?
Comment #30
xamountJust providing an update here (as we had some offline communications in Slack).
We have discovered the root cause. Long story short, we have a custom hook_page_attachments_alter() that uses the build() function.
However the build() function changed from alpha27+. So we need to update our code. If we did a straight copy/paste of most of your code in build() from alpha27+, it works.
But instead of doing it like this, we are trying to use one of the hooks like hook_schemadotorg_jsonld_alter() instead as this is the recommended way to achieve our customisations.
Apologies for this long issue which ended up being our custom code.
Comment #31
xamountChanged to fixed, as patch in this issue is still needed.
Comment #32
abhinand gokhala k commentedI have tried hook_schemadotorg_jsonld_alter in Alpha 29, and it is working fine without any caching issues when using the patch from #18.
Without the patch, I am facing the same issue mentioned in #13.
In conclusion, the issue mentioned in #13 is valid and resolved using the patch from #18.
However, the caching issue is not valid.
Thanks for the great support!