Problem/Motivation
Discovered in farmOS: https://github.com/farmOS/farmOS/issues/1090
Summary: We haven't been writing update hook when we made changes to the Log entity type definition, so the cached definition in the key_value table may be outdated.
It seems that this doesn't matter in most contexts, but can cause errors in others (like in the GitHub issue linked above).
Proposed resolution
We should review all changes that have been made to the Log entity type definition since v2 was released and provide an update hook that ensures they are reflected in the cached key_value entity type definition.
We should also make sure that update hooks are added in any future changes.
Remaining tasks
Review changes to the entity type definition since v2.Write an update hook that ensures those changes are reflected in the cachedkey_valueentity type definition.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork log-3604200
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
m.stentaLooking at the history of changes to
src/Entity/Log.php, there are a lot of changes... but I think we only need to focus on ones that have happened since the release of Log 2.0.0 (18 Oct 2021), since that is when we officially started supporting Drupal 8+. Furthermore, we only need to focus on changes to theContentEntityTypeannotation/attribute properties. That narrows it down to the following changes, which are all relatively recent (26 Jan 2024):Comment #3
m.stentaNotably, this one already included an update hook, added in #3600574: Use Drupal core RevisionHtmlRouteProvider.
Comment #5
m.stentaComment #6
m.stentaI removed this update because I don't think it actually works:
I'm not what the correct way to update
route_providersis... I'll see if I can find some precedent for this...Comment #7
m.stentaFWIW I tested all the other updates and they work as expected.
Comment #8
m.stentaI figured this out and restored the update hook for it.
It just needed to be
$entity_type->setHandlerClass('route_provider', $route_providers);instead of$entity_type->set('route_providers', $route_providers);.Tested and it works as expected.
Comment #9
m.stenta@pcambra in chat:
https://irc.farmos.org/bot/log/farmOS/2026-06-19#T104290