{"id":1247579,"date":"2017-03-01T06:49:32","date_gmt":"2017-03-01T14:49:32","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/"},"modified":"2017-03-01T18:45:50","modified_gmt":"2017-03-02T02:45:50","slug":"resource-urls-break-when-using-capistrano-symlinked-release-dirs","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/","title":{"rendered":"Resource URL&#8217;s break when using Capistrano (symlinked release dirs)"},"content":{"rendered":"<p>Currently, your tribe_resource_url function doesn&#8217;t seem to play well when the website is served out of a symlinked dir.<\/p>\n<p>I&#8217;m having to run the following code as a mu-plugin to work around the problem:<\/p>\n<p><code>&lt;?php<br \/>\nadd_filter('tribe_resource_url', function ($url) {<br \/>\n$root = dirname(dirname(__DIR__));<br \/>\nif (strpos($url, $root) === 0) {<br \/>\n$url = str_replace($root, home_url(), $url);<br \/>\n}<br \/>\nreturn $url;<br \/>\n});<\/code><\/p>\n<p>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.<\/p>\n<p>Here are the PATHS set in our config<\/p>\n<p><code>WP_SITEURL=https:\/\/ngs.staging.bigfish.co.uk\/wp<br \/>\nWP_HOME=https:\/\/ngs.staging.bigfish.co.uk<br \/>\nWP_CONTENT_URL=https:\/\/ngs.staging.bigfish.co.uk\/app<br \/>\nWP_CONTENT_DIR=\/var\/www\/ngs.staging.bigfish.co.uk\/current\/web\/app<br \/>\n<\/code><\/p>\n<p>With the webserver serving this folder:<\/p>\n<p><code> $_SERVER['DOCUMENT_ROOT'] = '\/var\/www\/ngs.staging.bigfish.co.uk\/current\/web'<\/code><\/p>\n<p>but the real directory, the content being in something like:<\/p>\n<p><code>\/var\/www\/ngs.staging.bigfish.co.uk\/releases\/XXXXXXXXX\/web<\/code><\/p>\n<p>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).<\/p>\n<p>So when you come to compile the resource URL we end up with something like this:<\/p>\n<p><code>\/var\/www\/ngs.staging.bigfish.co.uk\/releases\/20170228143114\/web\/app\/plugins\/the-events-calendar\/src\/resources\/js\/aggregator-admin-legacy-settings.js<\/code><\/p>\n<p>instead of:<\/p>\n<p><code>https:\/\/ngs.staging.bigfish.co.uk\/app\/plugins\/the-events-calendar\/src\/resources\/js\/aggregator-admin-legacy-settings.js<\/code><\/p>\n","protected":false},"template":"","class_list":["post-1247579","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Resource URL&#039;s break when using Capistrano (symlinked release dirs) -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Resource URL&#039;s break when using Capistrano (symlinked release dirs) -\" \/>\n<meta property=\"og:description\" content=\"Currently, your tribe_resource_url function doesn&#8217;t seem to play well when the website is served out of a symlinked dir. I&#8217;m having to run the following code as a mu-plugin to work around the problem: &lt;?php add_filter(&#039;tribe_resource_url&#039;, function ($url) { $root = dirname(dirname(__DIR__)); if (strpos($url, $root) === 0) { $url = str_replace($root, home_url(), $url); } return [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-02T02:45:50+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/\",\"name\":\"Resource URL's break when using Capistrano (symlinked release dirs) -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-03-01T14:49:32+00:00\",\"dateModified\":\"2017-03-02T02:45:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Community Events\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/community-events\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Resource URL&#8217;s break when using Capistrano (symlinked release dirs)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Resource URL's break when using Capistrano (symlinked release dirs) -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/","og_locale":"en_US","og_type":"article","og_title":"Resource URL's break when using Capistrano (symlinked release dirs) -","og_description":"Currently, your tribe_resource_url function doesn&#8217;t seem to play well when the website is served out of a symlinked dir. I&#8217;m having to run the following code as a mu-plugin to work around the problem: &lt;?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 [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/","article_modified_time":"2017-03-02T02:45:50+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/","name":"Resource URL's break when using Capistrano (symlinked release dirs) -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-03-01T14:49:32+00:00","dateModified":"2017-03-02T02:45:50+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/resource-urls-break-when-using-capistrano-symlinked-release-dirs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Community Events","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/community-events\/"},{"@type":"ListItem","position":5,"name":"Resource URL&#8217;s break when using Capistrano (symlinked release dirs)"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1247579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1247579\/revisions"}],"predecessor-version":[{"id":1248112,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1247579\/revisions\/1248112"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1247579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}