Doesn't work if Drupal is served from a subdirectory

Created on 27 March 2025, 30 days ago

I have a D9 (now upgrading to D10) in a subdirectory. The latest 3.1 version stopped working (it did work on the D9 compatible version).

I tracked this down to some logic where the replacement of the public path was done using the request host instead of the Drupal base url.

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡¦πŸ‡·Argentina hanoii πŸ‡¦πŸ‡·UTC-3

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

Merge Requests

Comments & Activities

  • Issue created by @hanoii
  • πŸ‡¦πŸ‡·Argentina hanoii πŸ‡¦πŸ‡·UTC-3

    MR!93 added.

  • Pipeline finished with Success
    30 days ago
    Total: 138s
    #458982
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Possible dup https://www.drupal.org/project/stage_file_proxy/issues/3499660 πŸ› Files are not proxied when Drupal is not in the webroot Needs work

    Either way probably should have a test

  • πŸ‡¦πŸ‡·Argentina hanoii πŸ‡¦πŸ‡·UTC-3

    Hmm, definitely a dupe, I tried searching for something similar but my keyword-fu was probably not on its peak. I will comment there, I think this patch is cleaner and rely on a core function rather than string replacements.

  • πŸ‡¦πŸ‡·Argentina hanoii πŸ‡¦πŸ‡·UTC-3

    Rebased

  • Pipeline finished with Success
    11 days ago
    Total: 233s
    #473932
  • πŸ‡§πŸ‡ͺBelgium lisotton Brussels

    Issue was already fixed in the latest version of the module.

  • πŸ‡¦πŸ‡·Argentina hanoii πŸ‡¦πŸ‡·UTC-3

    I kind of feel that this is a better fix, it's doing a lot of things that are really not necessary:

    diff --git a/src/DownloadManager.php b/src/DownloadManager.php
    index ae73c0c2cb17e267bf318f6a428810a10d2908b3..bf5a00e1a7762606b52ea5c6402f69d0874fa728 100644
    --- a/src/DownloadManager.php
    +++ b/src/DownloadManager.php
    @@ -140,11 +140,7 @@ final class DownloadManager implements DownloadManagerInterface {
        * {@inheritdoc}
        */
       public function filePublicPath(): string {
    -    $request = $this->requestStack->getCurrentRequest();
    -    $filesDir = PublicStream::baseUrl();
    -    $host = $request->getSchemeAndHttpHost();
    -    $basePath = $request->getBasePath();
    -    return str_replace($host . $basePath . '/', '', $filesDir);
    +    return PublicStream::basePath();
       }
     
       /**

    Why do all that to remove things from baseUrl() when base basePath() already gives yo what you want?

Production build 0.71.5 2024