Log error when using a non-existant permission iv views/access/Permission.php

Created on 21 June 2024, 3 months ago

Problem/Motivation

alexpott spotted this while reviewing this section from core/modules/user/src/Plugin/views/access/Permission.php as part of #3123067: Fix 'Drupal.Semantics.FunctionT.NotLiteralString' coding standard β†’ .

  public function summaryTitle() {
    $permissions = $this->permissionHandler->getPermissions();
    if (isset($permissions[$this->options['perm']])) {
      return $permissions[$this->options['perm']]['title'];
    }

    // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
    return $this->t($this->options['perm']);

The comment copied here for convenience,

I think this code is incorrect. I think it exists from a time when permissions were not enforced and did not create dependencies. I don't think translating a non-existent permission is the correct thing to do here. I think we should log an error and just return 'user.permissions'. That said this code might become completely unreachable once views config validation ensures that the permission exists.

Steps to reproduce

Proposed resolution

TBA

Remaining tasks

TBA

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

Comments & Activities

Production build 0.71.5 2024