Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This might be a site specific issue, but we're running into an issue where www.example.com css/js will reference assets from edit.example.com and vise versa (which ever domain generated the cache first).
Comment | File | Size | Author |
---|---|---|---|
#8 | advagg-2353811-8-kill-domain-reference.patch | 27.83 KB | mikeytown2 |
#3 | advagg-n2353811-3.patch | 696 bytes | DamienMcKenna |
#1 | domain_hash-2353811-1.patch | 584 bytes | cashwilliams |
Comments
Comment #1
cashwilliams CreditAttribution: cashwilliams commentedI see why advagg is changing asset urls to absolute full paths, but this is causing the issue. The only quick fix I can see is to add the domain/base_url to the hash key. This however does cause a duplicate of the aggregated files for each domain.
Comment #2
DamienMcKennaComment #3
DamienMcKennaShouldn't it also prefix the $file string with the $base_url in the static cache? That way if $base_url changes during the execution cycle it'll continue to reference the correct file?
Comment #4
siwinski CreditAttribution: siwinski commentedI am still getting cross-domain issues with #3. I am testing with a load balancer and 2 individual nodes. One of the individual nodes keeps getting the load balancer's aggregated files.
Comment #5
siwinski CreditAttribution: siwinski commentedThis may or may not help your situation, but here is how I solved this issue for my site:
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedPointed these 2 issues here
#2354161: CSS aggregation images url in HTTPS
#2347147: Domain was loaded oer https, but displayed insecure content
In all your cases, what's the value of $_SERVER["HTTPS"]? is it "on"?
Also go to admin/config/development/performance/advagg/info and under "Hooks And Variables Used In Hash" you'll see is_https listed; if that's empty and your on a https site then turning on $_SERVER["HTTPS"] should fix the issue. The http/https switch gets recorded in the 3rd base64-ed hash of the filename as it's a configuration variable. I think the contents_alter trick will modify the 2nd hash as that's a hash of the contents. $base_url might be needed; if it is then using the hash value from admin/config/development/performance/advagg/info might be the ideal way.
Comment #7
cashwilliams CreditAttribution: cashwilliams commentedis_https is properly set to true when loading the site on it editorial/secure domain.
is_https is null when loading the site over http as a anonymous user.
Comment #8
mikeytown2 CreditAttribution: mikeytown2 commentedCame up with a couple of solutions for this issue. With this patch AdvAgg will now convert absolute paths to be self references if possible & convert absolute paths to be protocol relative paths.
Completely killing the base_url portion takes care of the domain issue & using protocol relative path for things that don't match the base_url takes care of any http/https issues that might be lurking around.
I also added in the option to include the base_url variable in the hooks hash array as that will cause a different aggregate to be created for every permutation of the base_url variable. I do believe the relative & protocol relative options are better than this though as it allows for the same css/js files to be used on different domains.
Marked this as fixed because it's been committed. Reopen with any bugs you find :)
Comment #11
mikeytown2 CreditAttribution: mikeytown2 commented2nd commit was a re-ordering of the admin page; moved more settings to be under the new obscure fieldset.
Comment #13
therobyouknow CreditAttribution: therobyouknow commentedHas anyone else found solution here in comment #5 https://www.drupal.org/project/advagg/issues/2353811#comment-9276923 from @swinski to be successful? Thank you @swinski I have tried your solution but been unsuccessful so far. Here is how I setup the test and the outcome: https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6519#issueco...
What module did you put your code in @swinski ? When I tried to do the same, make use of your code suggestion by putting it in one of my custom modules, the code did not run, as I checked with both xdebug and some debug code. I followed the hook naming convention etc to ensure my function correctly named. Some info about what I did in that same link above.
I also looked at @mikeytown's subsequent comment here for a solution #8 https://www.drupal.org/project/advagg/issues/2353811#comment-9609605 but saw that this is already in the version of the module I'm running: 7.x-2.8.
So on the basis that the above 2 solutions #5 and #8 didn't work for me, I am now wondering if the latest version of the module will have resolved this, between my version 7.x-2.8 and the latest 7.x-2.35 there are 100s of fixes for various things https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6519#issueco... and I am wondering if among those, this issue here is fixed.
This issue is "Closed (fixed)" - so what actual specific code change makes this issue to be fixed and closed?
Comment #14
therobyouknow CreditAttribution: therobyouknow commentedcredit to colleague Ben Scott with this solution:
https://github.com/NaturalHistoryMuseum/scratchpads2/issues/6519#issueco...