Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The core database update process invokes the entity definition updates prior to any other update hooks. This will throw exceptions on sufficiently old databases/betas (see #2530940: Provide beta7 update tests for instance). Since these exceptions are unhandled, no update hooks that attempt to resolve those very same exceptions can be run.
Proposed resolution
Replace the core service with one provided by this module that can disable the entity definition updates using a flag stored via the State API.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#1 | entity-definition-updates-2532356-01.patch | 2.06 KB | jhedstrom |
Comments
Comment #1
jhedstromThis works remarkably well (testing in #2530940: Provide beta7 update tests).
Comment #2
amateescu CreditAttribution: amateescu as a volunteer commentedWow, this is the only thing needed in order to override a core service? That's awesome :)
A tiny nitpick: we should use StateInterface here.
Comment #3
Berdir#2533282: Make schema methods' visibility public in SqlContentEntityStorage made me think...
What if.... we change the order of update functions to always run entity updates *last*? That gives update functions the changes to run first and correct whatever needs manual correction and then entity update can jump in and take care of the remaining stuff?
Then this wouldn't be needed anymore I think.
Comment #4
jhedstromThat makes sense to me. That would effectively do the same thing that gets done here, except one could potentially only need to run updates once.
Comment #5
jhedstromHowever, changing the order would not provide a workaround for #2533282: Make schema methods' visibility public in SqlContentEntityStorage.
Comment #6
jhedstromI added #2534832: Run entity definition updates after update hooks for core.
Comment #7
-enzo- CreditAttribution: -enzo- at Anexus commentedI did a small local change to patch #1 to force disable_entity_definition_updates in a migration from Beta11 to Beta12
Maybe we could use the beta2beta settings or maybe provide instructions to modify the update.
Outside this the patch works like a charm thank @jhedstrom
Comment #8
jhedstrom#2535082: Allow hook_update_N() implementations to run before the automated entity updates went into core which makes the need for this unnecessary.