Uncaught Error: Class "Drupal\commerce\Entity\CommerceContentEntityBase" not found

Created on 26 June 2025, about 1 month ago

Problem/Motivation

PHP Fatal error: Uncaught Error: Class "Drupal\commerce\Entity\CommerceContentEntityBase" not found in -drupal-10.4.x/html/modules/contrib/commerce_recruiting/src/Entity/Campaign.php:76

Steps to reproduce

When I install modules, I get this error.
It is because of the autoload in composer.json.
I haven't installed commerce yet.
Commerce_recruiting extends commerce: Campaign extends CommerceContentEntityBase but Commerce isn't available

Proposed resolution

remove autoloaders from composer.json

"autoload": {
"psr-4": {
"Drupal\\commerce_recruiting\\": "./src"
}
},
"autoload-dev": {
"psr-4": {
"Drupal\\Tests\\commerce_recruiting\\": "./tests/src"
}
},

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

8.2

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

    This is not working because it is too late in the process. autoload-test is fine, but the other is causing problems as commerce is not autoloaded.

  • πŸ‡©πŸ‡ͺGermany ktpm

    Hi,

    I removed the autoload section from the composer.json. Please update to the latest dev version and try again.

    Note added: I did not notice any change or unexpected behaviour of the module, neither before nor after removing the autoload, module enabled or disabled. The described issue is not what I have observed from composer so far. Maybe there are version or plugin differences? But I agree that the autoload is most likely not needed in modules (anymore?) and probably comes from a template which I resorted to back then.

    I hope it helps!

  • πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

    super thankful for the change. I created a local patch to remove it and it worked well so I am looking forward to converting back to yours.

Production build 0.71.5 2024