Needs review
Project:
Schema.org Metatag
Version:
3.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
14 Sep 2023 at 11:40 UTC
Updated:
15 Aug 2026 at 19:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mathilde_dumond commentedPatch that fixes that for us.
Comment #3
mathilde_dumond commentedComment #6
anybody@mathilde_dumond could you add a test maybe?
Comment #7
anybodyComment #8
ngal commentedI confirmed the root cause and wrote the test @anybody asked for in #6, and while testing MR !101 I hit a regression that I fixed.
neverExplode()has been dead code since the module started requiring Metatag 2.x. InprocessItem()the separator branch is tested first:hasSeparator()isis_callable([$this->metatagManager, 'getSeparator']), and since Metatag 2.0MetatagManageruses theMetatagSeparatortrait, so that method always exists.composer.jsonrequiresdrupal/metatag:^2.0, so theelsebranch cannot be reached on any supported install. Every nested value is split on the separator, including free text.MR !101 makes
neverExplode()win unconditionally. That fixes the free text case, but it also stops the pivot from ever seeing more than one value, because exploding is what feeds the pivot. Driving the real classes with the site separator, MR !101 turns this input:into three addresses that each repeat the whole unsplit string:
This is exactly what #3133218 ("streetAddress should explode") reports, so the two issues pull in opposite directions. With
textadded to the list the same thing happens to FAQ pages: a pivoted set of five questions collapses into one Question holding all five questions and all five answers in two strings.Free text only needs to stay intact when nothing consumes the extra values. A pivot is the only process that turns a list of values back into a list of objects, so the two cases can be told apart:
$this->pivotedis set once inoutput()by walking the value for apivotkey before the items are processed. Without a pivot the extra values would be rendered as several values of a property that takes one, which is what search engines report as a duplicate field, so there is nothing to lose there. With a pivot the current behaviour is kept exactly.The patch also adds
texttoneverExplode(), as proposed in #3134041-23.sameAslist, no pivotThe one behaviour change beyond the bug is
recipeInstructionswithout a pivot, which stops being split into a list. The list it produced was not reliable, since "Mix the flour, sugar and salt,Add the eggs,Bake for 30 minutes" already came out as four fragments rather than three steps. Sites that want the list can set a separator that does not occur in the text, or enable the pivot.tests/src/Unit/SchemaNameBaseExplodeTest.phpcovers four cases: free text kept without a pivot, free text exploded with a pivot, other properties still exploded, and a custom separator. It builds the tag without the plugin system, since the Metatag plugin constructor needs the container, so it stays a unit test.ExplodeTestTagis a separate file to keep the one class per file rule.Two things:
pivotcheck is per tag, not per branch. If one branch of a tag is pivoted, free text elsewhere in the same tag still explodes. Making it per branch means replacingarray_walk_recursive()with a walk that tracks the path. That is more precise but a bigger change, and the current shape never produces output worse than the release does today.longannotation on the sub property, the same flag would express "this is free text, do not explode it" without a list. That would be a good follow up once #3425455 lands, and would letneverExplode()be deprecated.Since this issue and #3593489 describe the same defect, whichever one you prefer to keep, the other can point at it.