Fatal error in DomainStorage::postLoad() - Class name must be a valid object or a string in Drupal 10

Created on 15 May 2025, about 2 months ago

Issue Summary

When using the Domain module (version 2.0.0-beta2) with Drupal 10, a fatal PHP error occurs during cache rebuilds and site loads:

PHP Fatal error: Uncaught Error: Class name must be a valid object or a string in /path/to/web/modules/contrib/domain/domain/src/DomainStorage.php:210

This occurs because the $this->entityClass property can be an object in Drupal 10, but the module code assumes it's always a string.

Additionally, there is a secondary issue with $this->moduleHandler()->getImplementations() calls that are no longer compatible with Drupal 10.

Steps to Reproduce

1. Install Drupal 10.4.x
2. Install Domain module 2.0.0-beta2
3. Run drush cr or load the site in a browser
4. Observe the fatal error

Proposed Solution

The attached patch:

1. Adds type checking for $this->entityClass to handle both string and object cases
2. Replaces getImplementations() calls with invokeAll() for better Drupal 10 compatibility

The patch maintains compatibility with both Drupal 9 and Drupal 10.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine a.novolokov Kharkiv

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

Comments & Activities

Production build 0.71.5 2024