DeleteAction class can return wrong access result

Created on 7 August 2024, 3 months ago
Updated 8 August 2024, 3 months ago

Problem/Motivation

DeleteAction::access method can grant access even if parent method denies it.

Steps to reproduce

Related source code:


 // Bail if the object is not an entity or access is denied.
    if (!$object instanceof EntityInterface || !$access->isAllowed()) {
      return $return_as_object ? $access : $access->isAllowed();
    }

I think it is a typo, condition above is suggesting to forbid the access.

Proposed resolution

I suggest this adjustment:

 if (!$access->isAllowed()) {
      return $return_as_object ? $access : $access->isForbidden();

I think the condition for object type can be skipped too, because the class extends Drupal\Core\Action\Plugin\Action\EntityActionBase that probably has that check (but I didn't check this part).

I didn't face the problem with access practically, I have just found it in code. Drupal probably use to request $access variable as object, so the bug does not occur. That's why I set it as minor bug.

Remaining tasks

No other changes needed.

User interface changes

No changes needed.

API changes

No changes needed.

Data model changes

No changes needed.

πŸ› Bug report
Status

Needs work

Version

1.2

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia tomas.teicher

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

Comments & Activities

Production build 0.71.5 2024