EntityInformationManager::$entityTypes must not be accessed before initialization

Created on 18 March 2025, 24 days ago

Problem/Motivation

When doing a clean site install from config with the entity information module enabled, I get an error:

Error: Typed property Drupal\entity_information\EntityInformationManager::$entityTypes must not be accessed before initialization in Drupal\entity_information\EntityInformationManager->getPluggedEntityTypes() - line 124

Steps to reproduce

Perform a site install from config with the entity information module enabled.
Observe the error being thrown

Proposed resolution

Make sure the values are always properly initialized

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands seanB Netherlands

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

Comments & Activities

  • Issue created by @seanB
  • 🇳🇱Netherlands seanB Netherlands

    Patch is attached.

  • 🇳🇱Netherlands seanB Netherlands
    1. +++ b/src/EntityInformationManager.php
      @@ -16,11 +16,11 @@ use Drupal\Core\Routing\UrlGeneratorInterface;
      -   * The url generator service.
      

      The URL generator was not used. So removed that.

    2. +++ b/src/EntityInformationManager.php
      @@ -34,21 +34,14 @@ class EntityInformationManager extends DefaultPluginManager {
      +  protected array $entityTypes = [];
      

      This initializes the variable to fix the error.

    3. +++ b/src/EntityInformationManager.php
      @@ -34,21 +34,14 @@ class EntityInformationManager extends DefaultPluginManager {
      +  protected array $entityBundles = [];
      

      Same here.

Production build 0.71.5 2024