Deprecate NodeStorageInterface::revisionIds in favor of entity query

Created on 16 July 2018, over 6 years ago
Updated 19 August 2024, 4 months ago

Problem/Motivation

In #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder β†’ we are having to get all the revision IDs for entity that we just know is revisionable.

We have generic code

   $entity_type = $this->entityTypeManager->getDefinition($entity->getEntityTypeId());
    if ($revision_table = $entity_type->getRevisionTable()) {
      $query = $this->database->select($revision_table);
      $query->condition($entity_type->getKey('id'), $entity->id());
      $query->fields($revision_table, [$entity_type->getKey('revision')]);
      $query->orderBy($entity_type->getKey('revision'), 'DESC');
      return $query->execute()->fetchCol();
    }
    return [];

Proposed resolution

That should work for any revisionable entity. Can we move NodeStorageInterface::revisionIds on up to RevisionableStorageInterface and then implement this generic logic in \Drupal\Core\Entity\Sql\SqlContentEntityStorage?

Remaining tasks

Is this ok with BC policy.
Write patch
Tests

User interface changes

None

API changes

RevisionableStorageInterface would have ::revisionIds()

Data model changes

NOne

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
EntityΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

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.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Came up in slack and the advice from @berdir was to deprecate instead. I agree as it's minimal code to get a list of revision IDs using an entity query.

Production build 0.71.5 2024