Problem/Motivation

An InvalidArgumentException occurs when accessing an entity's revisions list if no revision exists in the currently active language.
The exception is thrown from Drupal/Core/Entity/Controller/VersionHistoryController::loadRevisions, which is called from Drupal/Core/Entity/Controller/VersionHistoryController::revisionOverview.
This doesn't affect nodes, as nodes use \Drupal\node\Controller\NodeController::revisionOverview to display the list of revisions.

Steps to reproduce

I oringinally experienced this issue with a custom entity, but this seems to also happen on all entities that use the VersionHistoryController such as the core \Drupal\block_content\Entity\BlockContent entity.

Here are steps to reproduce with the BlockContent entity:

  1. Install using standard profile in English
  2. Enable Content Translation module
  3. Add the French language
  4. Create a BlockContent type under /admin/structure/block-content
  5. Enable ‘Show language selector on create and edit pages’ and ‘Enable translation’ options in the block type's ‘Language Settings’
  6. Create and place an instance of such a block under /admin/structure/block
  7. Switch the site's language (I am using the language switcher for this)
  8. Visit the block's revisions page under /admin/content/block/1/revisions
  9. Notice that the exception is thrown

Proposed resolution

Change the Drupal/Core/Entity/Controller/VersionHistoryController::loadRevisions function to check if a language exists for each revision with hasTranslation before loading it with getTranslation.

Remaining tasks

Fix Drupal/Core/Entity/Controller/VersionHistoryController::loadRevisions
Add test coverage

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3589757

Command icon 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

semiaddict created an issue. See original summary.

semiaddict’s picture

I submitted an MR for this.
Attached is a patch.

cilefen’s picture