• Resolved llmarlou

    (@llmarlou)


    Hi there,

    We have encountered a possible bug with the ‘Redirect to file’ option.

    For our installations we don’t use the default WordPress setup and the /uploads/ folder is a symlink to another folder outside the WP installation.
    After the 4.5.92 update, we have specified the ‘other downloads path’ (as described in https://www.download-monitor.com/kb/add-path/) and that works fine, it fixed all issues with ‘Access Denied’ errors.

    So for example, we use /srv/http/shared/uploads/ as a custom path.
    The files are located in /uploads/dlm_uploads/year/month/

    However, it seems that the ‘Redirect to file’ option breaks whenever we activate this for a file (in our hosting setup). Enabling this option results in a 404/page cannot be found error for that file.

    When this option is enabled the file redirects to a file with only (domain.ext)/dlm_uploads/ in the path, instead of the full url with (domain.ext)/uploads/dlm_uploads/ (so the /uploads/ folder is missing).

    Kind regards,
    Marlou

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Razvan

    (@raldea89)

    Hey @llmarlou ,

    Could you please tell us what plugin version you are using? Also, I’ve made a ticket on github where you can see its progress.

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    At the time of writing this post DLM was at 4.6.2. But I’ve just tested it in the latest version, 4.7.1, and it’s still an issue.

    Plugin Author Razvan

    (@raldea89)

    Hey @llmarlou ,

    Could you please make a page with a test Download so we can have a look? Also, could you please go to dashboard > Settings > Permalinks and click “Save changes” without modifying anything and see if that works?

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    Refreshing/flushing the permalinks didn’t fix it.

    Below are two examples, one with the redirect to file option enabled and one with a regular (working) download:

    Plugin Author Razvan

    (@raldea89)

    Hey @llmarlou ,

    Sorry for the late reply. If you use this filter hook here and add your symlinked directory in that array does it work for you?

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    Should it then look like this?

    $shortcuts = apply_filters( 'dlm_upload_shortcuts', array( wp_get_upload_dir()['/srv/http/shared/uploads/'] ) );

    Because that doesn’t seem to fix the issue.

    Plugin Author Razvan

    (@raldea89)

    The correct format would be :

    $shortcuts = apply_filters( 'dlm_upload_shortcuts', array( wp_get_upload_dir()['basedir], '/srv/http/shared/uploads/' ) );

    But I think I misunderstood something in the process. Is the symlink attached on wp-content/uploads or another directory, so if you try to go to wp-content/uploads you get redirected to ‘/srv/http/shared/uploads/’?

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    I’m sorry for my late reply.

    Our symlink: /wp-content/uploads/ -> /srv/http/shared/uploads/

    And the DLM files are inside /uploads/dlm_uploads/

    so if you try to go to wp-content/uploads you get redirected to ‘/srv/http/shared/uploads

    Yep, that’s correct.

    And the problem is that with the ‘redirect to file’ option enabled, the browser is pointing to <domain>/dlm_uploads/year/month/ instead of <domain>/uploads/dlm_uploads/year/month/
    So it’s skipping the /uploads/ folder in the path.

    Plugin Author Razvan

    (@raldea89)

    Thanks for the info Marlou.

    Did you try with the latest update?

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    No but I’ve just tried again with version 5.7.3 on our test environment. With 5.7.3 active, I then added the path to the symlinked directory in the array in Filemanager.php.

    After these changes I:
    – restarted php
    – flushed permalinks
    – deleted transients for DLM

    But this doesn’t seem to have fixed it.

    Plugin Author Razvan

    (@raldea89)

    Hey Marlou,

    Thanks for the info. Could you please modify these lines found in download-monitor/src/DownloadHandler.php, from line 528 to line 533, with the code found here and let me know if this solved your problem?

    Warmly,
    Razvan

    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    Thanks again for your help, appreciated.

    I’ve implemented the changes you suggested in the DownloadHandler.php file (on our acceptance environment, still running on DLM 4.7.3), but unfortunately it still doesn’t seem to fix it.

    Plugin Author Razvan

    (@raldea89)

    Is it possible to let me know in which of the ifs does the code enter?

    Warmly,
    Razvan

    Plugin Author Razvan

    (@raldea89)

    Hello @llmarlou ,

    Could you also pass here the results of wp_upload_dir(); so that I can understand better what is going on? If you are not comfortable with displaying information like this please use our contact form here.

    Warmly,
    Razvan

    • This reply was modified 1 year, 5 months ago by Razvan. Reason: forgotten word
    Thread Starter llmarlou

    (@llmarlou)

    Hi Razvan,

    I will get back to you on this with new input, next week. Thanks again!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Bug with ‘Redirect to file’ option’ is closed to new replies.