TrashEntityTypeManager causes compatibility error with getFieldDefinitions() method with devel_generate

Created on 23 July 2025, 22 days ago

Problem/Motivation

When the trash module is enabled alongside devel_generate, attempting to generate content results in a fatal error about method compatibility that shouldn't exist.

Error Message:
Declaration of Drupal\trash\TrashEntityTypeManager::getFieldDefinitions() must be compatible with Drupal\Core\Entity\EntityTypeManager::getFieldDefinitions($entity_type_id, $bundle = NULL)

The error message is misleading because
EntityTypeManager does not have a
getFieldDefinitions() method - this method only
exists in EntityFieldManager. The issue appears to
be that:

1. The trash module replaces the
entity_type.manager service with
TrashEntityTypeManager (in
TrashServiceProvider::alter())
2. Some code (possibly in devel_generate or
elsewhere) is incorrectly calling
getFieldDefinitions() on the entity type manager
service
3. This results in a fatal error with a confusing
error message

Steps to reproduce

1. Install Drupal 10.5.x with trash module
(3.x-dev) enabled
2. Enable devel_generate module
3. Attempt to generate content using devel_generate
4. Observe the fatal error

Proposed resolution

Add a proxy method to TrashEntityTypeManager that forwards getFieldDefinitions() calls to the correct service (entity_field.manager). This provides compatibility with code that incorrectly expects this method on the entity type manager.

Ultimately it would be good to find out what is calling the wrong class

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇺🇸United States SocialNicheGuru

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

Comments & Activities

  • Issue created by @SocialNicheGuru
  • 🇺🇸United States SocialNicheGuru

    Error: [error] Error: Call to undefined method
    Drupal\trash\TrashEntityTypeManager::getFieldDefi
    nitions() in eval() (line 1 of
    /var/www/html/vendor/drush/drush/src/Commands/cor
    e/PhpCommands.php(32) : eval()'d code)
    #0
    /var/www/html/vendor/drush/drush/src/Commands/cor
    e/PhpCommands.php(32): eval()
    #1 [internal function]:
    Drush\Commands\core\PhpCommands->evaluate()
    #2 /var/www/html/vendor/consolidation/annotated-c
    ommand/src/CommandProcessor.php(276):
    call_user_func_array()
    #3 /var/www/html/vendor/consolidation/annotated-c
    ommand/src/CommandProcessor.php(212):
    Consolidation\AnnotatedCommand\CommandProcessor->
    runCommandCallback()
    #4 /var/www/html/vendor/consolidation/annotated-c
    ommand/src/CommandProcessor.php(175):
    Consolidation\AnnotatedCommand\CommandProcessor->
    validateRunAndAlter()
    #5 /var/www/html/vendor/consolidation/annotated-c
    ommand/src/AnnotatedCommand.php(387): Consolidati
    on\AnnotatedCommand\CommandProcessor->process()
    #6 /var/www/html/vendor/symfony/console/Command/C
    ommand.php(326): Consolidation\AnnotatedCommand\A
    nnotatedCommand->execute()
    #7 /var/www/html/vendor/symfony/console/Applicati
    on.php(1096):
    Symfony\Component\Console\Command\Command->run()
    #8 /var/www/html/vendor/symfony/console/Applicati
    on.php(324): Symfony\Component\Console\Applicatio
    n->doRunCommand()
    #9 /var/www/html/vendor/symfony/console/Applicati
    on.php(175):
    Symfony\Component\Console\Application->doRun()

  • 🇮🇳India AkashKumar07

    I have added a patch to fix it. Please review.
    Thanks!

  • I was not able to reproduce the error. I tested on a DrupalPod environment running D10.5.1 with the 3.x-dev version of the module and version 5.4.0 of devel_generate.

  • 🇷🇴Romania amateescu

    I also can't reproduce this. What entity type were you trying to generate?

  • 🇺🇸United States SocialNicheGuru

    I am changing this to a support request. This was an issue, now it is not. I am wondering if there was an interaction with another module.

  • 🇷🇴Romania amateescu

    An interaction with another module is my guess as well. I think what would need to happen for this error to appear is for an entity class to use the entity type manager instead of the entity field manager in FieldableEntityInterface::getFieldDefinitions(), in which case that entity class needs to be updated.

    Closing for now but feel free to reopen if you bump into it again and can point to the problematic entity type.

Production build 0.71.5 2024