Needs work
Project:
Drupal core
Version:
main
Component:
asset library system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2023 at 16:38 UTC
Updated:
30 Apr 2023 at 18:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersComment #4
wim leersThe test failure confirms the suspected regression 😔
Comment #5
catchThis is probably it.
Comment #6
catchApparently not - I don't have Drupal installed in a subdirectory locally, so getting the test to fail the right way wasn't happening. Maybe we need an additional call to ::transformRelative()?
Comment #8
wim leersAlternative patch for #2 to verify that this fails on
10.0too.Comment #9
wim leersI think this is why this is a false alarm.
This is wrongly requesting a root-relative URL in
$hrefprefixed by the base URL, which includes the hostname AND the subdirectory in which Drupal is installed.Which is just plain wrong! 🙈
Unfortunately,
\Drupal\Tests\UiHelperTrait::drupalGet()does not know how to follow links: it cannot handle root-relative URLs 😳 So we need this:Let's find out…
Comment #10
wim leersCorrect patch.
Comment #11
wim leersAlternatively:
… if #10 is green, then I'm going to close this. Sorry for the noise 🙈
I now wonder how this worked fine for about a decade 😅
Comment #13
catchI spent more time than I care to admit trying to make the test pass in so many different ways (every way I could think of to generate a file URL), didn't occur to me that the test might be broken!
However in the process of that, I did wonder if we should be doing this instead when building the asset URI. If we wanted to, we can remove the file URL generator from CssCollectionOptimizerLazy and should also make the js version work the same way. The urldecode is extremely annoying though, so we might want a follow-up for that bit.
I also think we could keep the test coverage here (once the test is correct :P).
Comment #14
catch#10 is green, but happier issue title rather than closing, at least for now.
Comment #15
ambient.impactThat's basically been a recurring thought for me when trying to get a complex site up and running on DigitalOcean's App Platform with multiple containers of the site code, some web accessible and some not with different addresses - I ran into many problems with the asset system and how it rewrites URLs in aggregated CSS that are largely off topic here (see kind of hacky and temporary decorated
CssOptimizeron GitHub) but just saying yup, same.Comment #16
wim leersSame thing here 😅🫣
Yes, we should! Query strings and fragments in
url(…)references in CSS files is one of the things that has been causing bug reports against the CDN module for over a decade:And I think
\Drupal\Tests\cdn\Unit\File\FileUrlGeneratorTest::urlProvider()now provides a pretty solid/comprehensive set of test cases: https://git.drupalcode.org/project/cdn/-/blob/4.0.1/tests/src/Unit/File/.... We'd want to change that to not be CDN-simulated of course, but other than that, if we'd test a CSS file containing every edge case listed there, we'd be better off for sure.Hah, that is that other edge case which has seen many bug reports over the years, but I can only quickly find this one: #1719568: CDN URLs are not properly encoded in some edge cases.
That too is covered by that same test case I just linked 😊
@catch Would you be interested in me porting that test coverage to core?
Comment #17
catchOpened #3354211: Tidy up URL generation for asset aggregates for the asset URL generation clean-up.
@Wim that sounds good, it might help one of the many related issues on #2669074: Convert file_create_url() & file_url_transform_relative() to service, deprecate it.
Comment #18
catchCan't think of anything else here.
Comment #19
longwaveThis comment won't mean much to us in the future, let's add something a bit more descriptive.