Block Content entities lose their revision ID in special cases

Created on 20 January 2016, about 9 years ago
Updated 6 May 2023, over 1 year ago

Discovered this as the root cause of #2651198: Latest Version tab shows on block_content even when there is no forward revision β†’ .

Here's the deal. Workbench Moderation adds a new local task to any revisionable content entity, which in core means nodes and block content. This local task is bound to a route, which has a custom access checker that hides the route if there is no forward revision of an entity. The entity that it checks is passed to it.

When routing, everything works fine and the page is accessible or not as appropriate. On other tabs on the block (Delete and Devel), everything works fine and the page is accessible or not as appropriate.

On the block edit page, and ONLY the block edit page (/block/{id}), there is a problem. Specifically, one thing Workbench Moderation does is add its own param converter, which simply extends the core EntityConverter class. When viewing the Edit page, that converter is called twice, once during routing and once from within the tab-building system. In both cases, EntityConverter calls $entity = $storage->load($value);.

When called from routing, the entity is not yet in the static cache and so is loaded from storage, and cached, and $entity->entityKeys has 4 entries: id, uuid, bundle, and revision.

When that load() call is invoked later, from within the tab building process, the entity is already statically cached... but $entity->entityKeys is now lacking the revision key!

As a result, $entity->getRevisionId() (which Workbench Moderation calls later) returns NULL, which is not == to the latest revision ID (of course), and thus the tab shows up as though there were a forward revision.

This issue appears ONLY on the block_content edit tab and nowhere else. It does not affect nodes, and does not affect other tabs on the block content entity.

I'm well past my ability to debug this, but hopefully this will be enough for someone with more knowledge of entities and/or blocks to pick it up and find the root issue.

πŸ› Bug report
Status

Closed: outdated

Version

9.5

Component
Block contentΒ  β†’

Last updated 20 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States Crell

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024