Problem/Motivation

This is only an issue I ran across while doing a PHPStan of a custom module at level 8. The media module has the same issue I ran across for my custom module.

MediaAccessControlHandler in the media module has this:

if ($account->hasPermission($this->entityType->getAdminPermission())) {
hasPermission is defined as only accepting a string, but getAdminPermission returns ?string.

Steps to reproduce

I haven't seen a crash or warning from this, but someone else saw an issue in a contrib module:
https://www.drupal.org/project/drupal/issues/3416110

Proposed resolution

I'm not entirely clear on where the change needs to be made, but I'll create an MR with one possibility.

Issue fork drupal-3587247

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tolstoydotcom created an issue.

tolstoydotcom’s picture

I can't change the MR, but my change is for line ~55 of MediaAccessControlHandler:

    $permission = $this->entityType->getAdminPermission();
    if (is_string($permission) && $account->hasPermission($permission)) {

ishani patel made their first commit to this issue’s fork.

ishani patel’s picture

Hello, @tolstoydotcom
I've raised MR Kindly review it.

Thank you!

tolstoydotcom’s picture

LGTM, thanks.