Resource URL’s break when using Capistrano (symlinked release dirs)

Home Forums Calendar Products Community Events Resource URL’s break when using Capistrano (symlinked release dirs)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1247579
    bigfishdesign
    Participant

    Currently, your tribe_resource_url function doesn’t seem to play well when the website is served out of a symlinked dir.

    I’m having to run the following code as a mu-plugin to work around the problem:

    <?php
    add_filter('tribe_resource_url', function ($url) {
    $root = dirname(dirname(__DIR__));
    if (strpos($url, $root) === 0) {
    $url = str_replace($root, home_url(), $url);
    }
    return $url;
    });

    With capistrano you have a releases dir, with a symlink point to a current dir. The current dir is what is served up by the webserver.

    Here are the PATHS set in our config

    WP_SITEURL=https://ngs.staging.bigfish.co.uk/wp
    WP_HOME=https://ngs.staging.bigfish.co.uk
    WP_CONTENT_URL=https://ngs.staging.bigfish.co.uk/app
    WP_CONTENT_DIR=/var/www/ngs.staging.bigfish.co.uk/current/web/app

    With the webserver serving this folder:

    $_SERVER['DOCUMENT_ROOT'] = '/var/www/ngs.staging.bigfish.co.uk/current/web'

    but the real directory, the content being in something like:

    /var/www/ngs.staging.bigfish.co.uk/releases/XXXXXXXXX/web

    Because you are using a number of PHP functions to read the current dir, it will return the real dir rather than what the webserver and WordPress says where it is (symlinked dir).

    So when you come to compile the resource URL we end up with something like this:

    /var/www/ngs.staging.bigfish.co.uk/releases/20170228143114/web/app/plugins/the-events-calendar/src/resources/js/aggregator-admin-legacy-settings.js

    instead of:

    https://ngs.staging.bigfish.co.uk/app/plugins/the-events-calendar/src/resources/js/aggregator-admin-legacy-settings.js

    #1248116
    Cliff
    Member

    Hi, Big Fish.

    Thanks for that detailed report.

    I’ve passed it along to our developers.

    I’ll mark this ticket as Pending Fix, which means this thread should receive a reply once the applicable fix has been released. I cannot guarantee when it will be fixed as it’s in the development team’s hands now. They need to assign it, code it, test it, and schedule it for release.

    I apologize for this issue and appreciate your understanding and patience.

    The best I can tell you right now is that this was a previously-logged-and-fixed bug that apparently wasn’t… so we’ll have them look into it again for you.

    Thank you for sharing all the details, including your System Information Report.

    #1326690
    Cliff
    Member

    Big Fish, sorry for the long-delayed reply here.

    Community Events went through a significant code update.

    Could you please confirm if this issue is still an outstanding one to be fixed or did it get resolved on its own?

    Thank you.

    #1328447
    Cliff
    Member

    Hi, Big Fish.

    Just checking back here to see if you got my previous message asking if the bug is still outstanding.

    Our developers are standing by awaiting your report.

    Thank you.

    #1335047
    Brook
    Participant

    Howdy Big Fish,

    I looked into this and am not able to determine what the problem is. WordPress registers both the symlinked and realpaths using wp_register_plugin_realpath(). Our code here relies on plugins_url(), thus it should be able to accept either the symlink or realpath all while returning the proper URL.

    None of us have Capistrano setup so we can not test your exact scenario. What happens if you create a test plugin, and pass plugins_url() both parameters, with __FILE__ as the second parameter? Does it return the correct URL, or does it contain the release/xxxxxx bits? If it does not return the correct URL, near as I can tell your server is somehow not compatible with WP’ handling of symlinks. Unfortunately that’s not a bug we can fix. If it is returning the correct URL, there might be something we can do.

    I really appreciate you taking the time to reach out and share your findings. I wish I was able to find a solution for you right off the bat.

    – Brook

    #1344917
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Resource URL’s break when using Capistrano (symlinked release dirs)’ is closed to new replies.