Hi!

* I upgraded to CDN 7.x.-2.3
* I went to the website and all images being displayed via the CSS files were missing.
* I checked out the 7.x-2.x branch from git and my images came back after I went back to the commit:
143e46e196d323dd986d8cee7058905a4d9aa771 So I determined that the problem was in the next commit.

It comes down to the new security tokens added to the URL. The changes made were:

File: cdn.module
Function: cdn_file_url_alter

AND

File:cdn.basic.farfuture.inc
cdn_basic_farfuture_download($token, $ufi, $path)

* The images come back when I comment out the check for security token.

* I also noticed that the images I'm getting once they show up agian have the exact same token as the css file that is calling them

* We do not have css aggregation turned on.

I'm happy for any suggestions! :)

Jaime.

Comments

Wim Leers’s picture

Component: Module » Documentation
Assigned: Unassigned » Wim Leers
Category: bug » support
Status: Active » Fixed

I forgot to document this; sorry. You have to rebuild your menus, so that the new Far Future URLs actually work, plus you have to clear the CSS cache so that the file URLs in the CSS files (usually to images, but also fonts, for example) are updated to the new style.

You can do that:
- with Drush: drush cc menu && drush cc css+js.
- just through Drupal's UI: submitting the modules page and clicking "Clear Cached data" at admin/settings/performance in D6 or clicking "Clear all caches" at admin/config/development/performance in D7

Now documented in http://drupal.org/node/1441480 and http://drupal.org/node/1441482.

Wim Leers’s picture

Title: Images in css files inheriting the security token » File URLs broken after upgrade to version 2.3
Wim Leers’s picture

Title: File URLs broken after upgrade to version 2.3 » File URLs broken after upgrade to version 2.3 (cache clearing was not documented)
jaime@gingerrobot.com’s picture

Status: Fixed » Active

Thankyou for the quick response Wim! I did do a drush cc all when I updated the module. I also ran an updatedb and cron as well.

The two key things I noticed during my testing:

1. The security token given to the images served is the same token that the css file has.

2. The images are not being passed through cdn_file_url_alter(&$original_uri). I logged all content having their urls altered and none of the images came into the logs.

Wim Leers’s picture

1. I just noticed this happens for files that have not been aggregated.
2. Which images? CSS background images? If so, this is the same bug as #1.

Working on this, even though I really don't have time for this.

jaime@gingerrobot.com’s picture

Thankyou for your help Wim,

It looks like all the images in the css file are background images.

I hope this helps other CDN users as well.

Jaime.

Wim Leers’s picture

jaime@gingerrobot.com’s picture

Hi, I've tried your patch on the release for 2.3 and on the current git. Neither seems to fix the problem. I still see same sec token in the urls for both css file and all the background images it's calling for.

I'll investigate a bit more and see if I can find anything new taking into consideration the changes you've made.

Thankyou,

Jaime.

Wim Leers’s picture

Status: Active » Needs review

@jaimekristene: Did you clear the CSS cache?

theunraveler’s picture

I also tried the patches (and cleared menu and css+js caches) on both 6.x-2.x and 6.x-2.3 and the issue was not fixed.

Wim Leers’s picture

#10: can you describe the exact nature of your problem by posting some of the problematic URLs?

Wim Leers’s picture

Oh and with the CSS aggregation changes, you may also want to rebuild your theme registry.

Wim Leers’s picture

Status: Needs review » Fixed

The follow-up patch for #1428530: Override CSS aggregation to ensure correct file URL altering for files referenced by CSS files that I mentioned in #7 should have fixed this.

jaime@gingerrobot.com’s picture

Status: Fixed » Active

I just tested the latest version from git.
commit a4ab5ea350c0c4051b1bf062b1a006f1a4974476

This issue is still not fixed for me. What I am still seeing is images being requested by CSS files have the same token as the css file itself.

We have turned the far_future module off for now.

I always do a drush cc all before testing anything.

Jaime.

Wim Leers’s picture

#14: I believe you think you did everything right, but I'm convinced you made a mistake somewhere. There's custom CSS aggregation now. It's near impossible that it works for everybody except for you. Also, the relevant issue is actually #1428530: Override CSS aggregation to ensure correct file URL altering for files referenced by CSS files, not this one.

Maybe the APC cache is messing up your results? I've seen this happen too. See http://stackoverflow.com/questions/911158/how-to-clear-apc-cache-entries on how to clear it.

Are you using the AdvAgg module maybe?

It would be even better if you could do a vanilla Drupal installation and give that a try.

andreiashu’s picture

Status: Active » Postponed (maintainer needs more info)

Hi Wim,

Shouldn't we have a checkbox in the Admin UI to enable the 'cdn_theme_layer_fallback' variable? Basically a user has the ability to enable far future URLs but doing just this WILL break their images that have relative URLs in CSS files. So, if one doesn't have other helper modules (like advagg + parallel css module enabled) one should be informed that she needs to enable 'cdn_theme_layer_fallback' as well. In this case a checkbox just beneath the far future option would make sense?

Let me know your thoughts.

andreiashu’s picture

I forgot to mention: I'm seeing this from a D6 point of view - although the settings should be the same for D6 and D7?

Wim Leers’s picture

1) There's no fallback mode in D7. Fallback mode only exists to not require patching core. Patching core is only necessary in D6. Hence this mode only exists in D6.
2) Fallback mode is enabled automatically. See _cdn_requirements_detect_fallback(), which is called automatically for every CDN admin page. Users will have to visit the CDN admin page to configure it in the first place, hence this function will be called. If it's never called, then no CDN integration happens anyway, so nothing breaks.
3) I don't see why this would break relative URLs in CSS files? Fallback mode + Far Future expiration works just fine. Parallel CSS is obsolete.

Overall: yes, things are hackier in D6. But that's because of the fallback mode, which I only added to remove the need for patching core for those who can't/don't dare or know.

jaime@gingerrobot.com’s picture

Hi!

Thankyou Wim for being very patient with me. I have figured what was going wrong for me.

I read your messages on the other ticket http://drupal.org/node/1428530#comment-5558316

In my dev environment I have 'preprocess_css' => FALSE AND 'cdn_farfuture_status' => TRUE

I needed "Aggregate and compress CSS files"/'preprocess_css' => TRUE for far future to work.

Sorry I didn't read the other ticket properly before now.

Thankyou again.

Jaime.

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Fixed

I'm glad you appreciate my time :)

Also: you've just made an extremely good point: I need to document that you need to enable CSS aggregation for Far Future expiration to work well! I just did that:
- D7: http://drupalcode.org/project/cdn.git/commit/4946c7e
- D6: http://drupalcode.org/project/cdn.git/commit/e4b7256

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.