Problem/Motivation
This problem was pointed out by @Berdir:
content_moderation_entity_access() adds the $account
object as a cacheable dependency, which is an uncacheable AccountProxy
object.
Additionally, it also adds each \Drupal\workflows\Transition
returned by \Drupal\content_moderation\StateTransitionValidation::getValidTransitions()
object as a cacheable dependency, which are uncacheable objects as well.
The initial purpose for adding those dependencies was based on @Wim Leers's feedback from #2725533-64: Add experimental content_moderation module (point 10), but they were implemented wrongly by me :/
Proposed resolution
Since \Drupal\content_moderation\StateTransitionValidation::getValidTransitions()
returns a list of transitions based on user permissions, that's the only cacheable dependency we need to use.
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.