Account created on 9 May 2023, about 1 year ago
#

Recent comments

Hi cmlara, I can't thank you enough for your valuable input on this matter; after combing through our modules a bit we were able to locate the issue coming from IMCE File manager somehow. I haven't pinned down exactly why and I'd love to have that answer, but I wanted to report here so the thread can be closed for tidiness. Thank you again and I hope you have a great Monday!

As a follow up, I found my php server's error logs and they also print the same error:

[26-May-2023 09:26:46 America/New_York] Uncaught PHP Exception Symfony\Component\Routing\Exception\InvalidParameterException: "Parameter "filepath" for route "system.private_file_download" must match ".+" ("" given) to generate a corresponding URL." at /code/web/core/lib/Drupal/Core/Routing/UrlGenerator.php line 203

Hey there, thanks for these leads! I'll follow them in order here:

I would suggest looking at \Drupal\system\PathProcessor\PathProcessorFiles or any other InboundPathProcessor’s your environment has.

Diving in to these is something I was hesitant about, I couldn't understand how to define my own inbound path processor correctly; do I need to make a manual entry here with my own arbitrary labels? I think I have a stock-standard Inbound PathProcessorFiles.php at that location:

class PathProcessorFiles implements InboundPathProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function processInbound($path, Request $request) {
    if (strpos($path, '/system/files/') === 0 && !$request->query->has('file')) {
      $file_path = preg_replace('|^\/system\/files\/|', '', $path);
      $request->query->set('file', $file_path);
      print_r('ticket');
      return '/system/files';
    }
    print_r('no ticket');
    return $path;
  }

}

I'm really on new ground here, and I'd love to understand more; you can see I've got a couple of print_r statements to try and grasp what is happening here. I think I correctly understand that this method is called any time a link needs to be rendered server-side, and that I can add my own logic here to set variables like $file_path to be passed in to the request as URL parameters. As far as I can tell, this looks correct for handling inbound files.

I've also taken a look at my system.routing file, specifically the entries you mention there:

system.files:
  path: '/system/files/{scheme}'
  defaults:
    _controller: '\Drupal\system\FileDownloadController::download'
    scheme: private
  requirements:
    _access: 'TRUE'

system.private_file_download:
  path: /system/files/{filepath}
  defaults:
    _controller: '\Drupal\system\FileDownloadController::download'
  requirements:
    # Permissive regex to allow slashes in filepath see
    # http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html
    filepath: .+
    _access: 'TRUE'

I initially thought this was the issue, but anywhere I've seen documentation of these entries seems to make these look correct, including the regex pattern being passed to the filepath property. I've tinkered with arbitrarily changing these values to see what breaks, and this configuration seems to be correct (based on poorly evidenced deductive logic. I'm doing my best but man, am I out of my depth here!).

The full stack trace (or failing that breakpoint in a dev lab) might be more revealing.

Here's a look at the reports I know to gather:
- The Reports tab's Recent Log Messages
- The white error page resulting from visiting the link
Unfortunately, these two report nearly identical error messages and don't really have a stack trace as far as I can see. My diagnostic knowledge here is limited ^_^;;

I hope that's a helpful reply, thank you again for looking in to this with me.

Hi @cmlara and thanks for taking the time to look at this, your module is great.

Hovering over a url produces this format url:
https://xyz.abc.io/system/files/human_readable_label.pdf

Production build 0.69.0 2024