[warning] Undefined array key "langcode" DrupalKernel.php

Created on 27 November 2024, 25 days ago

Problem/Motivation

Post update system_post_update_add_langcode_to_all_translatable_config(&$sandbox = NULL) is clearing langcode from config system.site

     // If this config contains any elements (at any level of nesting) which
    // are translatable, but the config hasn't got a langcode, assign one. But
    // if nothing in the config structure is translatable, the config shouldn't
    // have a langcode at all.
    if ($typed_config->hasTranslatableElements()) {
      if ($config->get('langcode')) {
        continue;
      }
      $config->set('langcode', $default_langcode);
    }
    else {
      if (!array_key_exists('langcode', $config->get())) {
        continue;
      }
      $config->clear('langcode');
    }
    $config->save();

But below code is trying to fetch langcode from system.site config which conflicting with above post update.

[warning] Undefined array key "langcode" DrupalKernel.php:1395
[warning] Undefined array key "langcode" DrupalKernel.php:1396

     // Store the default language values on the container. This is so that the
    // default language can be configured using the configuration factory. This
    // avoids the circular dependencies that would created by
    // \Drupal\language\LanguageServiceProvider::alter() and allows the default
    // language to not be English in the installer.
    $default_language_values = Language::$defaultValues;
    if ($system = $this->getConfigStorage()->read('system.site')) {
      if ($default_language_values['id'] != $system['langcode']) {
        $default_language_values = ['id' => $system['langcode']];
      }
    }

Steps to reproduce

  • Upgrade Drupal core 10.2.3 from to 10.3.10
  • Executed database updates
  • Run any drush command ex: drush cr and observe warning Undefined array key "langcode" DrupalKernel.php

Proposed resolution

Add a check if langcode config present or clean up the code in DrupalKernel.php checking langcode

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.3

Component

configuration system

Created by

🇮🇳India sirishayarlagadda

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

Comments & Activities

Production build 0.71.5 2024