The media_entity_download_count_file_access function doesn't skip the /media/add/X path properly

Created on 28 March 2023, over 1 year ago

Problem/Motivation

We get an access denied error when uploading files from the media library, using this module.
This is because of the following code:

    $path = \Drupal::request()->getpathInfo();
    $arg  = explode('/', $path);
    if ($arg[0] == 'media' && $arg[1] == 'add') {
      return;
    }

Having the path as /media/add/image the exploded array is
[
0 => "",
1 => "media",
2 => "add",
3 => "image"
]

So this check will never be met.

Proposed resolution

Change the if function to check 1 and 2 instead of 0 and 1

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium michel.g

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

Comments & Activities

Production build 0.71.5 2024