Problem/Motivation
https://git.drupalcode.org/project/drupal/-/commit/e878713656faabf6d3afd... committed as part of the solution for #2327883: Field [storage] config have incomplete settings until they are saved could introduce a regression that most likely related to Content Moderation and the moderation_state field.
Report 1
I have updated Drupal core from 10.1.8 to 10.2.2. Drush updb is successful but when I do config import I am getting issue for field core.base_field_override.node.content_type_name.promote as below
[error] Error: Call to a member function getSettings() on null in Drupal\Core\Field\FieldConfigBase->getSettings() (line 372 of /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Field/FieldConfigBase.php) #0 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Field/FieldConfigBase.php(287): Drupal\Core\Field\FieldConfigBase->getSettings()
1 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(430): Drupal\Core\Field\FieldConfigBase->postCreate()
#2 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(357): Drupal\Core\Config\Entity\ConfigEntityStorage->_doCreateFromStorageRecord()
#3 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(1059): Drupal\Core\Config\Entity\ConfigEntityStorage->importCreate()
#4 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(842): Drupal\Core\Config\ConfigImporter->importInvokeOwner()
#5 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(663): Drupal\Core\Config\ConfigImporter->processConfiguration()
#6 /home/vsts/work/1/s/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php(561): Drupal\Core\Config\ConfigImporter->processConfigurations()Report 2
We were updated a project from Drupal 10.1.8 to 10.2.7 and clean site install from existing config via drush si -y --existing-config started to fail with the same backtrace. See the complete backtrace in comment #16.
Steps to reproduce
Report 2 repro steps
- Install a Drupal 10.2.7 site from the recommended project and by using the Standard profile.
- Enable the Content Moderation module.
- Enable the "Editorial" default workflow for the Article content type.
- Install the Base Field Override UI module as a convenient solution for creating base field overrides.
- Modify the Moderation State base field's label to "Foo" on the Article content type at
admin/structure/types/manage/article/fields/base-field-override/node.article.moderation_state - Export all site configuration via
drush cex - Modify config/sync/core.extensions.yml and change the install profile from standard to minimal.
- Try to install the site from existing configuration via
drush si -y --existing-config
Proposed resolution
Only run the logic added to \Drupal\Core\Field\FieldConfigBase::postCreate() in the previous commit when a site is not being installed from config.
Remaining tasks
Repro steps and/or...- Test coverage
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A
Original report by [username]
(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | call_to_a_member_function_getSettings_on_null_3441962_27.patch.patch | 4.28 KB | rajiv.singh |
| #27 | ISSUE_SUMMARY_FOR_DRUPAL_ORG.txt | 6.66 KB | rajiv.singh |
Issue fork drupal-3441962
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
adarshv commentedHi @ ashetkar, I've tried to reproduce the issue but I'm not getting the error.
Comment #3
ashetkar commentedI am getting this issue for base field override config.
Comment #4
cilefen commentedHow does the import configuration differ from the running configuration? Why are you importing configuration after upgrading? You should be exporting.
Comment #5
ashetkar commentedWhen we commit code and send to server at server end import config is getting failed for existing configuration. I have exported configuration but there is no change for base_field_override related config.
Comment #6
cilefen commentedHow does the import configuration differ from the running configuration on the server end?
Comment #7
ashetkar commentedHow does the import configuration differ from the running configuration on the server end? - No it's not different all config starts base_field_override is getting failed. Please find below one of the config name : core.base_field_override.node.page.promote.yml
uuid: 69be9e46-6806-4c5d-83c7-bf3312538678
langcode: en
status: true
dependencies:
config:
- node.type.page
_core:
default_config_hash: vdYkuvvyzCU3dFiOu7LULd-uZyENb_byNYidQVIZtXk
id: node.page.promote
field_name: promote
entity_type: node
bundle: page
label: 'Promoted to front page'
description: ''
required: false
translatable: false
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean
Comment #8
cilefen commentedIn what way does the import configuration differ from the running configuration? You can see the diff at the configuration sync UI.
It looks like the field storage definition is missing.
Comment #9
ashetkar commentedPromote is not field it is an attribute. We are overriding default promote attribute in field override.
Comment #10
euclid.hThe error suggests an issue with the promote field configuration for the node content type during configuration import.
Drupal compares file-based configuration with database-stored configuration during import, updating the latter if necessary. The error indicates a problem with the promote field's configuration, likely due to improper loading.
After upgrading Drupal core or modules, you may need to import configuration to update the configuration stored in the database to match the new codebase.
This is why you're performing a configuration import after upgrading
Comment #11
ashetkar commentedI have compared drupal core (core/lib/Drupal/Core/Field/) FieldConfigBase.php file for version 10.1.8 and 10.2.5. 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.5/core/lib/Drupal/...
Above code added newly in 10.2.5 version which is not allowing import for base_field_override fields. I have added patch where i removed above code.
Comment #12
wanjee commentedGot the same error message on full (re)install after applying an update of Drupal from 10.1 to 10.2.6.
On a perfectly fine environment I applied composer update, executed drush updb then exported the config.
Then when I try to reinstall the project using `drush -y site-install minimal --site-name="Test" --account-name=admin --account-pass=password --config-dir="../config/sync"` I got the error mentioned above during "install_config_import_batch" task.
The issue does not show on install when the patch proposed by ashetkar in #11 is applied.
(Reinstall using that command is part of our workflow to facilitate life of all developers working on the project)
After this clean install if I run drush cex I don't see any config change so I don't fix this is related to incorrect configuration management in the project.
The error I got was related to config core.base_field_override.node.ad_group.moderation_state.yml
Comment #13
gun_dose commentedI had the same error on
drush sicommand. Patch from #11 fixed the problemComment #14
mxr576The mentioned commit in #11 is with us since 10.2.0, We have also bumped a similar failure that was reported in this issue.
https://git.drupalcode.org/project/drupal/-/commit/e878713656faabf6d3afd...
Comment #15
mxr576Those who are also suffering from this problem, do you also have Content Moderation module enabled on your projects?
I enabled debug logging and I see a bunch of complains related to the moderation_state field, and for that field only.
Unexpected error during import with operation create for core.base_field_override.node.[node_type].moderation_state: moderation_state []Comment #16
mxr576Made this change and due to Monolog being active on the project since site install, I could capture this backtrace without spending hours on waiting for xDebug... not sure if it helps.
Comment #17
mxr576Comment #18
mxr576Hiding patch because it is not a solution, just a hack.
Comment #19
lauriiiThank you for posting the manual steps to reproduce this! A test case that consistently reproduces this would be really helpful as a potential next step.
Comment #21
mxr576I tried to put together repro steps by using a clean Drupal 10.2.7 install and with content moderation enabled, but I could not.
I did updated the issue description and I would have questions to @ashetkar:
drush cim -yruns on an existing project?Comment #22
mxr576Comment #23
mxr576I tried different base fields, the UID or the Promoted field on the Article content type, but I could only reproduce the issue by changing the Moderation State field. Proof:
I also could not reproduce the problem by importing a base field override via config import to an existing side (as @ashetkar's report indicated that). Proof:
Comment #24
sunlixHey,
we have the same behavior in our installations. New installation with
drush site:install --existing-configare not successfull if we have a content type configured to acontent_moderationworkflow.Beside this patch we have to apply the patch from #2321071: BaseFieldOverride fails to take into account ContentEntityInterface::bundleFieldDefinitions() when invoking onFieldDefinitionUpdate() to be able to successfull install from existing config.
Maybe that could related to each other. The error message differs but I think it is some kind of the same source issue.
Comment #25
quietone commentedFixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
Comment #26
mikemadison commentedI hit this yesterday on a site running Drupal 10.4.x. I was getting really inconsistent fatals mostly related to importing config override files (e.g. core.base_field_override.node.customer_case_study.status). Patching from this issue resolved for me. The patch did apply cleanly to 10.4.6.
Note that I wasn't trying to install from existing config, just doing a clean site-install and then a config-import after.
Comment #27
rajiv.singh commentedit is about the - Fatal error during config import when field storage definition is missing3441962