Call to a member function getSettings() on null in FieldConfigBase

Created on 24 May 2024, 5 months ago
Updated 3 July 2024, 4 months ago

Problem

I have upgraded drupal from 10.1.8 to 10.2.6 and there is no change in existing config but still getting runtime exception getSettings() function error for base_field_override config. Please find screenshot for same. During sync process, I am getting below error

Error: Call to a member function getSettings() on null in Drupal\Core\Field\FieldConfigBase->getSettings() (line 374 of FieldConfigBase.php)

Steps to reproduce

  1. Update core from drupal 10.1.8 to 10.2.6
  2. Run Drush updb and drush cex
  3. in site build, config impoert is breaking due call to a member function getSettings() on null.

I have compared drupal core (core/lib/Drupal/Core/Field/) FieldConfigBase.php file for version 10.1.8 and 10.2.6. I can see the below difference in code.

// Make sure all expected runtime settings are present.
$default_settings = \Drupal::service('plugin.manager.field.field_type')
->getDefaultFieldSettings($this->getType());
// Filter out any unknown (unsupported) settings.
$supported_settings = array_intersect_key($this->getSettings(), $default_settings);
$this->set('settings', $supported_settings + $default_settings);

https://git.drupalcode.org/project/drupal/-/blob/10.1.8/core/lib/Drupal/...
https://git.drupalcode.org/project/drupal/-/blob/10.2.6/core/lib/Drupal/...

Above code added newly in 10.2.6 version which is not allowing import for base_field_override field config. It doesn't ahhave any backward compatiability issue for 10.1.8 core. 10.2.6 code changes are done as part of this issue for Field [storage] config have incomplete settings until they are saved ( https://www.drupal.org/project/drupal/issues/2327883 🐛 Field [storage] config have incomplete settings until they are saved Fixed )

Proposed resolution
If $this->getSettings() is not defined or not available it should be handled.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Field 

Last updated about 14 hours ago

Created by

🇮🇳India ashetkar

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

Comments & Activities

Production build 0.71.5 2024