Support » Plugin: W3 Total Cache » CDN URL rewrite BROKEN for certain theme css files after latest update

  • atopps

    (@atopps)


    After the latest update I just ran tonight, when I view my page as an administrator (when caching should be off) there are several problems:

    – files are still loading from the CDN even though I have the “Don’t replace URLs for following user roles” option checked for all roles.
    – several theme files have a MISSING SLASH in the URL
    – instead of “http://cdn.pinleague.com/wp-content/themes/mytheme/style.css”
    – the url is “http://cdn.pinleague.com/wp-content/themesmytheme/style.css”
    – the cached version of the site appears to load fine.

    Also, if I turn off the CDN, everything loads fine in the admin view… so there’s something off about the way the CDN is implemented.

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frederick Townes

    (@fredericktownes)

    Could you please submit a bug submission form from the support tab of the plugin? Also there were no changes in the CDN functionality between .7 and .8, so issue is probably elsewhere.

    atopps

    (@atopps)

    Thanks Frederick. I did submit a bug report with the exact same issue about a week ago when I originally posted this.

    I found the issue in the lib/W3/plugin/CdnCommon.php file – thanks to this thread:
    http://wordpress.org/support/topic/w3tc-is-discarding-directory-structure-when-using-cdn?replies=3

    lines 544 and 550 of that file trim the URL. If you change the trim function to an ltrim function, that fixes the issue.

    atopps

    (@atopps)

    Here’s the full solution (until the next update) thanks to finglandj, as posted here (http://wordpress.org/support/topic/w3tc-is-discarding-directory-structure-when-using-cdn?replies=3)

    The problem is occurring because of an erroneous replacement.

    There is a script:

    (function(){
    				var srcStrt = "http://cdn10.brovadoweddings.com/blog/wp-content/uploads/p4/images/",
    					bioData = [{"filename":"biopic1_1303345244.jpg","url":""},{"filename":"biopic2_1303345256.jpg","url":""},{"filename":"biopic3_1303345281.jpg","url":""},{"filename":"biopic4_1303345304.jpg","url":""}],
    					picNum  = Math.floor(Math.random()*(bioData.length)),
    					markup  = '<img id="biopic" src="'+srcStrt+bioData[picNum].filename+'" width="260" height="390" alt="MN Wedding Photography | Minneapolis Wedding Photographers | Engagement Photographer bio picture" class="bio-col" />';
    				if ( bioData[picNum].url ) {
    					markup = '<a href="'+bioData[picNum].url+'">'+markup+'</a>';
    				}
    				document.write(markup);
    			})();

    srcStart is getting modified by uri_to_cdn_uri which trims the trailing slash.

    uri_to_cdn_uri is in w3-total-cache/lib/W3/Plugin/CdnCommon.php
    Lines 544 and 550 trim slashes from the returned url. Changing those to an ltrim ensures the directory structure is maintained.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CDN URL rewrite BROKEN for certain theme css files after latest update’ is closed to new replies.