Support core's collection permission in the permission provider

Created on 15 February 2024, 11 months ago

Problem/Motivation

Since Drupal 10.2.0 entity types may declare a collection permission. See https://www.drupal.org/node/2955178 or Allow entities to specify a "collection permission" Fixed . The permission providers, generate a "access {$entity_type_id} overview" permission, however, regardless of the value of the collection permission.

Steps to reproduce

Proposed resolution

If the entity type specifies a collection permission use that in EntityPermissionProviderBase::buildPermissions().

Since the permission is used in \Drupal\entity\Routing\DefaultHtmlRouteProvider::getCollectionRoute(), add the same fallback there. Once Drupal 10.2.0 is required for Entity API, the whole override can probably just be removed, because core already does the same thing now for any entity with a collection permission, but for now this seems like the least disruptive change.

Remaining tasks

User interface changes

-

API changes

The generated overview/collection permission now actually matches the specified collection permission, if any. I don't think it's reasonable to assume that people explicitly specify a collection permission but then expect Entity API to generate a different permission, so I think in all cases this can be considered an improvement, even if it is technically a behavioral change.

Data model changes

-

📌 Task
Status

Needs review

Version

1.0

Component

Core integration

Created by

🇩🇪Germany tstoeckler Essen, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tstoeckler
  • Status changed to Needs review 11 months ago
  • 🇩🇪Germany tstoeckler Essen, Germany

    Here we go. This is not extensively tested, but wanted to get the ball rolling.

    Not sending for a test run, because tests seem to be broken still, as far as I can tell.

Production build 0.71.5 2024