The "moderation_state" base field overrides cause install from existing config to fail

Created on 22 April 2020, over 4 years ago
Updated 27 March 2023, over 1 year ago

Problem/Motivation

This issue first got reported in #2321071-38: BaseFieldOverride fails to take into account ContentEntityInterface::bundleFieldDefinitions() when invoking onFieldDefinitionUpdate() .

The moderation_state base field overrides cause the Drupal install from existing config to fail.
See the explanation here #2321071-42: BaseFieldOverride fails to take into account ContentEntityInterface::bundleFieldDefinitions() when invoking onFieldDefinitionUpdate() and also the rest of the comments there.

To reproduce:
1. Install Drupal using the minimal profile
drush site-install minimal
2. Enable Content Moderation and Content Translation
drush en content_moderation content_translation -y
3. Create a CT
4. Create a workflow and enable it on the CT
5. Go to admin/config/regional/content-language and enable "Content", save
6. Export configuration. You should get a config_override file for the moderation_state base field.
drush cex -y
7. Install Drupal using the existing configuration
drush site-install --existing-config
TypeError: Argument 2 passed to Drupal\Core\Entity\ContentEntityStorageBase::onFieldDefinitionUpdate() must implement interface Drupal\Core\Field\FieldDefinitionInterface, null given, called in /home/herve/Documents/commission/drupal/drupal-core/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php on line 205 in /home/herve/Documents/commission/drupal/drupal-core/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php on line 463 #0 /home/herve/Documents/commission/drupal/drupal-core/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php(205): Drupal\Core\Entity\ContentEntityStorageBase->onFieldDefinitionUpdate(Object(Drupal\Core\Field\Entity\BaseFieldOverride), NULL)

Proposed resolution

1.
-> will not work, see #7

2.
-> will not work, see #12

3.
-> will not work, see #14

4.
-> will not work, see #17

5.
-> may not be ideal, see #19

6. Remove moderation_state from the "Content language" form using hook_form_language_content_settings_form_alter, which would prevent the BFO creation.

🐛 Bug report
Status

Needs review

Version

10.1

Component
Content moderation 

Last updated 1 day ago

Created by

🇧🇪Belgium herved

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024