S3fsCssOptimizer rewrites CSS that is stored locally when use_s3_for_public is on

Created on 31 July 2024, 8 months ago
Updated 15 August 2024, 7 months ago

Problem/Motivation

Since 10.1 introduced πŸ“Œ Make css/js optimized assets path configurable Fixed we have been storing aggregated in a local directory and this is working well.

We also have the following config enabled for S3FS:

  1. use_cssjs_host: false as files are local
  2. use_https: true
  3. use_s3_for_public: true

This means that this code still runs https://git.drupalcode.org/project/s3fs/-/blob/8.x-3.x/src/S3fsServicePr... to change the CSS optimizer - which then rewrites the CSS urls to be absolute.

This has a minimal impact, but it still seems unnecessary given the CSS files are not in S3 / the public scheme?

Steps to reproduce

  1. Enable config as above
  2. Include CSS with relative urls
  3. Observe they are rewritten by the module

Proposed resolution

Do not override asset.css.optimizer if > drupal 10.1? Or is there they some scenario where the assets are still ending up in S3 for some people?

Remaining tasks

  1. Decide on approach
  2. Implement

User interface changes

n/a

API changes

TBC

Data model changes

n/a

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand ericgsmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ericgsmith
  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    Observe they are rewritten by the module

    I recalled looking at this when we added support for assets:// and thinking β€œwhy don’t I need to disable this? Links are generating correctly but why?” and convinced myself that it was something with how the file pas passed over and location bypasses changing it to s3fs, I completely missed the script converting relative to absolute.

    Do not override asset.css.optimizer if > drupal 10.1?

    That would be the best solution.
    Simple \Drupal::version < 10.1 comparison before overriding is likely sufficient.

  • Pipeline finished with Success
    8 months ago
    Total: 359s
    #239902
  • Status changed to Needs review 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Opened MR with the change from above - it doesn't look like this would be applicable to v4 as the css / js functionality is in a sub module which could just be disabled (I assume - have not tested or looked at the 4.x branch)

  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    4.x should be fine as it is a submodule and can be enabled/disabled by choice (and there is a good chance I’m going to remove the code completely once D11 comes out).

  • Status changed to Fixed 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    Small change by maintainer prior to merging (caused by maintainer direction lacking sufficient detail in initial review).

    Thanks for locating this issue. Merging to Dev. Should go out this week when we tag D11 support.

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

Production build 0.71.5 2024