Undefined constant "Drupal\node\Entity\DRUPAL_OPTIONAL"

Created on 24 October 2023, about 1 year ago

Problem/Motivation

When updating an entity programmatically (for example when trying to change an entity storage class with devel_php) then the entire website runs under a 500 error: Undefined constant "Drupal\node\Entity\DRUPAL_OPTIONAL"

This also happen when running tests.

From investigation in #3304657:

The issue is that whatever we do, during bootstrap phase, Drupal loads all module files in core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php::handle(). This middleware has a priority of 100 to "Prepares the environment after page caching ran". Until we try to run a query on a middleware with a higher priority (in my case 210, just before page cache middleware), there is no way to have the const DRUPAL_OPTIONAL defined.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇭🇷Croatia Aporie

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024