Improve support for multi-value schema using Metatag's custom separator option

Created on 1 June 2018, over 6 years ago
Updated 10 June 2023, over 1 year ago

Issue:
This came up during configuration of recipe steps.. We passed a token to the recipeSteps field. The module then explodes the text by commas to indicate multiple steps, which is incorrect.

To reproduce:
Create a node with a text field (unlimited values).
Configure schema recipies for it. Recipe Steps are tied to this text field.
Add a single node with text with commas.
The Schema.org script contains the incorrect number of recipe steps because of the following code:

class SchemaMetatagManager
/**
* {@inheritdoc}
*/
public static function explode($value) {
$value = explode(',', $value);
$value = array_map('trim', $value);
//$value = array_unique($value);
if (count($value) == 1) {
return $value[0];
}

return $value;
}

Proposed fix:
Add a regex that will separate by comma, but not by "\,".
On implode, first escape all commas in the text with "\,".

✨ Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria jjchinquist Vienna, Austria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024