Different value then default

Created on 11 January 2024, 11 months ago

Problem/Motivation

In a multilanguage setup with NL as the default language and EN as the second installed language when entering a different value in the Description field a memory exhausted error occurs

Steps to reproduce

For example at admin/config/search/metatag/node/translate/en/edit I have the following different values for the Description field.

Now when adding a new EN node (so one which does not have a NL translation yet) I receive a memory exhausted error.

"NOTICE: PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/example/web/modules/contrib/metatag/src/MetatagManager.php on line 274"

  public function sortedTags() {
    $metatag_tags = $this->tagDefinitions();

    // Pull the data from the definitions into a new array.
    $tags = [];
    foreach ($metatag_tags as $tag_name => $tag_info) {
      $tags[$tag_info['group']][$tag_name] = $tag_info;
      $tags[$tag_info['group']][$tag_name]['label'] = $tag_info['label']->render();
    }

    // Sort the tags based on the group.
    $sorted_tags = [];
    foreach ($this->sortedGroups() as $group_name => $group) {
      $tag_weight = $group['weight'] * 100;

      // First, sort the tags within the group according to the original sort
      // order provided by the tag's definition.
      uasort($tags[$group_name], [
        'Drupal\Component\Utility\SortArray',
        'sortByWeightElement',
      ]);
      foreach ($tags[$group_name] as $tag_name => $tag_info) {
        $tag_info['weight'] = $tag_weight++;
        $sorted_tags[$tag_name] = $tag_info;
      }
    }

    return $sorted_tags;
  }

Rule 274
$tag_info['weight'] = $tag_weight++;

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.26

Component

Code

Created by

🇳🇱Netherlands undersound3

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

Comments & Activities

  • Issue created by @undersound3
  • 🇮🇳India samir_shukla bareilly

    Hi, Try increasing the php memory limit in php.ini as memory_limit = 512M or -1 and also try updating drupal settings with ini_set('memory_limit', '512M')(512M or -1);.

  • 🇳🇱Netherlands undersound3

    Thanks I tried increasing the memory earlier but even setting memory_limit = -1 is not helping.

    Seems the difference is casuing this memory exhaustion. Using the same value for EN as NL makes the problem go away...

Production build 0.71.5 2024