viewMode in Drupal\core_event_dispatcher\Event\Entity\EntityBuildDefaultsAlterEvent could be null in Drupal 9.4 somehow

Created on 12 September 2022, about 2 years ago
Updated 19 January 2023, almost 2 years ago

Problem/Motivation

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\core_event_dispatcher\Event\Entity\EntityBuildDefaultsAlterEvent::__construct(): Argument #3 ($viewMode) must be of type string, null given, called in /var/www/html/web/modules/contrib/hook_event_dispatcher/src/Plugin/Factory/EventFactory.php on line 24 in Drupal\core_event_dispatcher\Event\Entity\EntityBuildDefaultsAlterEvent->__construct() (line 44 of modules/contrib/hook_event_dispatcher/modules/core_event_dispatcher/src/Event/Entity/EntityBuildDefaultsAlterEvent.php).

Steps to reproduce

It is hard to reproduce because maybe there is something specific in my project but there is a fact that I did not have this problem with Drupal 9.3* and now with Drupal 9.4 it appears

Proposed resolution

I guess since there is no type specified for the $viewMode in hook_entity_build_defaults_alter - there shouldn't be type also in EntityBuildDefaultsAlterEvent

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

3.3

Component

Code

Created by

🇩🇪Germany Nikolay Borisov

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024