Improve cache dependencies in ContentTranslationDeleteAccess

Created on 4 January 2025, 29 days ago

Problem/Motivation

It loads all workflow only to add their cache tag, as any workflow might influence the access check.

That is slow (causes an extra config findByPrefix() query) and loads all those config entities, and it's also incorrect, as a new workflow might be added.

Steps to reproduce

Proposed resolution

Replace with a workflow_list cache tag. That said, this alone won't help, since the implementation then again loads all workflow entities.

However, we already have an API for this that doesn't require looping over them:

\Drupal\content_moderation\ModerationInformation::canModerateEntitiesOfEntityType and \Drupal\content_moderation\ModerationInformation::shouldModerateEntitiesOfBundle.

That relies on cached entity type and bundle information.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.1 🔥

Component

content_translation.module

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @berdir
  • 🇨🇭Switzerland berdir Switzerland

    Unsure what to do about the cache tags. We can depend on entity entity_bundles cache tag, because they get invalidated on any workflow change. But that implies that we know about the implementation of the content moderation API that we're using.

  • Pipeline finished with Failed
    29 days ago
    Total: 90s
    #385772
  • Pipeline finished with Failed
    28 days ago
    Total: 1213s
    #385917
  • Pipeline finished with Failed
    28 days ago
    Total: 90s
    #385935
  • 🇨🇭Switzerland berdir Switzerland

    Ok, this has a problem because it already needs this information in hook_entity_bundle_info_alter(). And we can't run after content_moderation, because the alter hook in content_moderation in turn depends on the translatable flag to be set.

    Added the direct check using workflow config entities for this case.

  • Pipeline finished with Failed
    27 days ago
    Total: 573s
    #386538
  • Pipeline finished with Failed
    27 days ago
    Total: 660s
    #386563
  • Pipeline finished with Failed
    26 days ago
    Total: 308s
    #387721
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Replace with a workflow_list cache tag. That said, this alone won't help, since the implementation then again loads all workflow entities.

    Why would adding a list cache tag load all entities?

    In case you're worried there are too many workflows that are not related to content moderation, we could introduce a few custom list cache tags in workflows so you can have something like: workflow_list:type:content_moderation

  • 🇨🇭Switzerland berdir Switzerland

    It used to, but the new implementation no longer needs to load.

Production build 0.71.5 2024