PHP warnings with Metatag module

Created on 9 January 2025, 13 days ago

Problem/Motivation

I have plenty PHP warnings when using the Metatag module, I think it is because the field storage may be special.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

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

Merge Requests

Comments & Activities

  • Issue created by @Grimreaper
  • 🇩🇪Germany Christian.wiedemann

    Hi,
    I can't reproduce this bug. I installed metatag and checked the field storage for field_metatag and the computed metatag. Any hint how I can that reproduce

  • 🇫🇷France Grimreaper France 🇫🇷

    I have the warnings on the MR of [10.1.x] Upgrade to UIP2 Active .

    But currently the installation is blocked by 🐛 Context error during installation Active , so I will try to reproduce on a standard install.

  • 🇫🇷France Grimreaper France 🇫🇷

    Got a clue.

    It is for some specific entity_type.

    Related to:
    - core.base_field_override.shortcut.default.metatag
    - core.base_field_override.simple_mega_menu.default.metatag
    - core.base_field_override.user.user.metatag

    These 3 config twice at each cache clear.

    I tried to reproduce on a fresh install. See screenshot of /admin/config/regional/content-language.

    But I don't know why on my fresh install, the config is saved, but when I export the config, there is no core.base_field_override.shortcut.default.metatag file.

    I will try to go deeper tomorrow.

    But then maybe it is legacy Metatag stuff in Sobki's config.

  • 🇫🇷France Grimreaper France 🇫🇷

    I think I found it.

    On my fresh install I had been able to get a core.base_field_override.user.user.metatag

    uuid: efad82a6-6b28-4c79-9766-25a1dffadff7
    langcode: en
    status: true
    dependencies:
      module:
        - metatag
        - user
    id: user.user.metatag
    field_name: metatag
    entity_type: user
    bundle: user
    label: 'Metatags (Hidden field for JSON support)'
    description: 'The computed meta tags for the entity.'
    required: false
    translatable: true
    default_value: {  }
    default_value_callback: ''
    settings: {  }
    field_type: metatag_computed
    

    Whereas on Sobki it looks like:

    uuid: fdac8baf-39e4-4353-8669-814967182c14
    langcode: en
    status: true
    dependencies:
      module:
        - user
    _core:
      default_config_hash: BggQQmc05YzF3dnZzbHBRHsnGQotgHAkAPzNLtewF3I
    id: user.user.metatag
    field_name: metatag
    entity_type: user
    bundle: user
    label: 'Metatags (Hidden field for JSON support)'
    description: 'The meta tags for the entity.'
    required: false
    translatable: false
    default_value: {  }
    default_value_callback: ''
    settings: {  }
    field_type: map
    

    The field type is not the same.

    So I guess it is a Metatag update that had not been correctly applied or a missing update in the Metatag module.

  • 🇫🇷France Grimreaper France 🇫🇷

    Nope.

    I have deleted my config. Resaved /admin/config/regional/content-language, so it had been recreated for simple_mega_menu and user (not for shortcut like on my other fresh install website).

    Recreated with "field_type: metatag_computed" for both user and simple_mega_menu but now the warning is in the previous foreach.

     foreach ($entity_type_fields_data["field_storages"] as $field_name => $field_storage_data) {
    ...
          $base_plugin_derivative = array_merge($base_plugin_definition, [
            'label' => $field_storage_data["label"],
    
  • 🇫🇷France Grimreaper France 🇫🇷

    On my fresh install website I don't pass in app/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php for field property derivative.

  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France Grimreaper France 🇫🇷

    So, happening not only with Metatag, but with other computed fields like path, menu_link, default_revision and customer_profiles (commerce).

    Not sure if this is the proper fix, if there is a better place to act, or better to change the foreach loop directly. But at least, I don't have warnings anymore.

    And for the warnings to happen, I had to use a component as a layout in my display and trigger this display. The component can be left empty of slots/props.

  • Pipeline finished with Failed
    6 days ago
    Total: 653s
    #397830
  • 🇩🇪Germany Christian.wiedemann

    Hi, now I fixed the problems during installation which are related to UI Patterns. This also fixes:
    https://www.drupal.org/project/ui_patterns/issues/3498496 🐛 Context error during installation Active

    I also add these two composer patches which fixes core issues.

    "drupal/core": {
    "Media Library: Argument #1 ($array) must be of type array, null given in array_filter().": "https://www.drupal.org/files/issues/2023-12-01/3340973-33.patch",
              "Warning: \"extra_field_block:node:*:content_moderation_control\" was not found": "https://git.drupalcode.org/project/drupal/-/merge_requests/9793/diffs.diff",
    }
    

    We had two issues:

    Two problems still exists.

    • Field user_picture crashes. This happens in SiteConfigurationForm::354;
    • it seems that default content content installation crashes .
  • 🇫🇷France pdureau Paris

    Let's talk about that tomorrow

Production build 0.71.5 2024