Support version negotiation for any entity type (currently only Node & Media are supported)

Created on 7 February 2019, over 5 years ago
Updated 6 October 2023, 8 months ago

Problem/Motivation

Version negotiation is only supported on node and media entities. This is because there was no generic revision access checker in core when #2992833: Add a version negotiation to revisionable resource types β†’ landed, but is now available since 9.3.0 as per #3043321: Use generic access API for node and media revision UI β†’ . We should support version negotiation for any entity type.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Fixed

Version

9.4

Component
JSON APIΒ  β†’

Last updated 1 day ago

Created by

πŸ‡©πŸ‡°Denmark Roensby

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡¦Ukraine Mykola Dolynskyi Poltava

    https://www.drupal.org/project/drupal/issues/3031271#comment-13706800 ✨ Support version negotiation for any entity type (currently only Node & Media are supported) Fixed

    @lois.chabrand , @PQ - thank you very much, with small changes that works good to drupal 9.5.2

  • πŸ‡ΊπŸ‡¦Ukraine Mykola Dolynskyi Poltava

    update to https://www.drupal.org/project/drupal/issues/3031271#comment-14884943 ✨ Support version negotiation for any entity type (currently only Node & Media are supported) Fixed - it was working good, until we deleted some nodes which share the paragraph

    afterthat we getting

    Error: Call to a member function getEntityType() on null in Drupal\jsonapi\Access\EntityAccessChecker>checkRevisionViewAccess() (line 249 of web/core/modules/jsonapi/src/Access/EntityAccessChecker.php)

        switch ($entity_type->id()) {
          case 'node':
          case 'media':
            $access = $entity->access('view all revisions', $account, TRUE);
            break;
          // Project-specific modification... Allow access to revisions of paragraphs
          // if the current user has access to the parent entity and to this
          // version of this paragraph. Note, this is not a perfect implementation.
          // Ideally we should be checking for access to the specific version of the
          // parent entity but there appears to be no way to do that with
          // information available at this point until
          // https://www.drupal.org/project/paragraphs/issues/2954512 is committed.
          case 'paragraph':
            assert($entity instanceof ParagraphInterface);
            $parent = $entity->getParentEntity();
            // Parent became grand parent
            while ($parent->getEntityType()->id() === 'paragraph') {
              $parent = $parent->getParentEntity();  // <--------- line 249
            }
    
  • πŸ‡ΊπŸ‡¦Ukraine Mykola Dolynskyi Poltava

    adding patch which overcomes https://www.drupal.org/project/drupal/issues/3031271#comment-15257741 ✨ Support version negotiation for any entity type (currently only Node & Media are supported) Fixed

    It basically ignores parent part of access check if parent is null

Production build 0.69.0 2024