- Issue created by @jesss
- Merge request !44Set multiple to FALSE in the plugin annotation for SchemaReviewReviewBody. β (Open) created by jesss
- last update
over 1 year ago 62 pass
In schema_review
, if the reviewBody field contains commas, it is always exploded into an array, despite being listed in neverExplode()
.
Example:
Despite its unimaginative construction, inherent pleasures persist in One Life, but it reeks of all the emotional complexity of an inspirational Facebook video.
"reviewBody": [
"Despite its unimaginative construction",
"inherent pleasures persist in One Life",
"but it reeks of all the emotional complexity of an inspirational Facebook video."
]
This is because the schema for that field sets multiple
to TRUE
.
* @MetatagTag(
* id = "schema_review_review_body",
* label = @Translation("reviewBody"),
* description = @Translation("Review body."),
* name = "reviewBody",
* group = "schema_review",
* weight = 11,
* type = "string",
* secure = FALSE,
* multiple = TRUE,
* property_type = "text",
* tree_parent = {},
* tree_depth = -1,
* )
*/
This means that in processItem()
in SchemaNameBase.php
, $explode
for this field is always set to TRUE
, and the logic never proceeds to check neverExplode()
.
protected function processItem(&$value, $key = 0) {
if ($key === 0) {
$explode = $this->multiple();
}
elseif ($this->schemaMetatagManager->hasSeparator()) {
$explode = TRUE;
}
else {
$explode = !in_array($key, $this->neverExplode());
}
I'm not sure why this field is marked as potentially having multiple items. Per the documentation on schema.org, it should just be a simple text field.
So, I'd propose updating the schema to set multiple
to FALSE
.
If this field is in fact supposed to allow multiple values, the entire logic string in processItem()
will need to be reworked instead. This is further complicated by the fact that the $key
is not passed to processItem()
in the case of simple strings like reviewBody so the array check as written would fail even if that branch of the logic were reached.
Active
3.0
Code