Commas in FAQpage questions and answers produce duplicate name and text

Created on 6 May 2020, over 4 years ago
Updated 14 August 2023, over 1 year ago

We have an issue where if the question or answer uses a comma, when looking at the structured data the question and answer is split accross 2 so Google throws an error: 'Duplicate field acceptedAnswer.text is not allowed' or 'Duplicate field name is not allowed.'

Images attached.

πŸ› Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

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.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Is there anything still needed for this, now that ✨ Improve support for multi-value schema using Metatag's custom separator option Fixed has been committed?

  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    The problem persists with Metatag 2.0 and Schema Metatag 3.0.1

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Thanks for confirming it.

    This needs to be rerolled.

  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    We have a WYSIWYG editor (v5) text field containing a text with multiple breaks (br tag). The text is then split in the schema at the br-tags and for each br-tag a text property is inserted.

  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    It looks like this, that even with commas in the text the property is split up

  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I have to revise my statement. It is only commas and not br tags. Sorry for the disturbance.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Patch Failed to Apply
  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I'm not sure I understand it correctly.

    But shouldn't the text property also appear in Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase::neverExplode()? And then wouldn't the order of the $explode query in Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase::::processItem() have to be adjusted and checked first for neverExplode() and then for hasSeparator?

        if ($key === 0) {
          $explode = $this->multiple();
        }
        elseif ($this->schemaMetatagManager->hasSeparator()) {
          $explode = TRUE;
        }
        else {
          $explode = !in_array($key, $this->neverExplode());
        }
    

    becomes

        if ($key === 0) {
          $explode = $this->multiple();
        }
        elseif (!in_array($key, $this->neverExplode()) {
          $explode = TRUE;
        }
        else {
          $explode = $this->schemaMetatagManager->hasSeparator();
        }
    
  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I am not sure about the type "text". Is it allowed to use it multiple times somewhere?

    A quick test with adding "text" to neverExplode() and with the following ruleset at Drupal\schema_metatag\Plugin\metatag\Tag\SchemaNameBase::processItem() fixes the problem:

        switch (true) {
          case $key === 0:
            $explode = $this->multiple();
            break;
          case in_array($key, $this->neverExplode()):
            $explode = FALSE;
            break;
          case !in_array($key, $this->neverExplode()):
            $explode = TRUE;
            break;
          case $this->schemaMetatagManager->hasSeparator():
            $explode = TRUE;
            break;
          default:
            $explode = FALSE;
        }
    
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Out of interest, if you change the Metatag module's delimiter from a comma to something else, does this problem go away?

  • πŸ‡©πŸ‡ͺGermany J-Lee πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I have missed this configuration :(
    If I set it to something else, the issue is fixed.

  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Thanks for letting us know.

Production build 0.71.5 2024