Warning: Undefined array key " moderation_state" in Drupal\Core\Field\Entity\BaseFieldOverride->getBaseFieldDefinition()

Created on 10 May 2024, about 2 months ago

Problem/Motivation

User with Moderator permissions has no access to the site and gets PHP errors:

  • Warning: Undefined array key " moderation_state" in Drupal\Core\Field\Entity\BaseFieldOverride->getBaseFieldDefinition()
  • Error: Call to a member function getFieldStorageDefinition() on null in Drupal\Core\Field\Entity\BaseFieldOverride->getFieldStorageDefinition()

Steps to reproduce

I was asked to upgrade a site with Drupal core 8.8 to Drupal 10. I am currently at the intermediary state with core Drupal core 9.5 and am hoping to proceed with further upgrades over the next days.

The Administrator role has no issues with acces. However, the user with Moderator permissions has no access to the site and gets two consequtive PHP errors:

1.

Warning: Undefined array key " moderation_state" in  Drupal\Core\Field\Entity\BaseFieldOverride->getBaseFieldDefinition() (line  165 of  /home/foosite/foosite.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php)

The line 165 of /home/foosite/foosite.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php is as follows:

/**
* Gets the base field definition.
*
* @return \Drupal\Core\Field\BaseFieldDefinition
*/
protected function getBaseFieldDefinition() {
 if (!isset($this->baseFieldDefinition)) {
   $fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($this->entity_type);
   $this->baseFieldDefinition = $fields[$this->getName()];
 }
 return $this->baseFieldDefinition;
}

2.
Error: Call to a member function getFieldStorageDefinition() on null in Drupal\Core\Field\Entity\BaseFieldOverride->getFieldStorageDefinition() (line 112 of /home/foosite/foosite.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php)

The line 112 of /home/foosite/foosite.com/web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php is as follows:

**
* {@inheritdoc}
*/
public function getFieldStorageDefinition() {
 return $this->getBaseFieldDefinition()->getFieldStorageDefinition();
}

Please advise.

πŸ› Bug report
Status

Closed: won't fix

Component

Code

Created by

πŸ‡ΉπŸ‡·Turkey TitaCvetkovic

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

Comments & Activities

  • Issue created by @TitaCvetkovic
  • Status changed to Closed: won't fix about 2 months ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    This sandbox is unsupported - it became workbench moderation which then went into core as content moderation

    Thanks

Production build 0.69.0 2024