Tidy up URL generation for asset aggregates

Created on 14 April 2023, over 1 year ago
Updated 4 September 2023, about 1 year ago

Problem/Motivation

Discovered on πŸ› Add additional test coverage for CssOptimizer Needs work .

Steps to reproduce

Proposed resolution

This already runs through the file url generator in CSS collectio renderer so we can pass a stream wrapper URI with a query string. Note the urldecode() though which should not be necessary.

Remaining tasks

We don't need the file URL generator injected if we do it this way. Also needs applying to JS collection optimizer.

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
Asset libraryΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom catch

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @catch
  • πŸ‡¬πŸ‡§United Kingdom catch
  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    This issue is a followup to πŸ› [regression] Since #1014086 generated CSS assets have absolute URLs without varying by url.site cache context Fixed that was tagged, 'Needs tests'. I removed the tag over there because it was explained in #3354204-8: [regression] Since #1014086 generated CSS assets have absolute URLs without varying by url.site cache context β†’ that tests would be added in the followup, that is, this issue.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Tests are actually in πŸ› Add additional test coverage for CssOptimizer Needs work .

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    30,051 pass
  • πŸ‡¬πŸ‡§United Kingdom catch

    Here's a patch for what the result would look like, but I don't think this is an improvement currently.

    Two issues:
    1. not sure how to do constructor bc with property promotion.

    2. I think we need to postpone this on an issue to add urldecode to fileUrlGenerator somehow.

  • Status changed to Needs work about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    So needs work, but should be postponed on that issue, however I'm not even sure what the file generator issue would look like.

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

    I've only quick glanced this based on a ping in another issue so If I make an error my apologies in advance.

    To me the call to urldecode() and the comment that its a call to a streamWrapper with the query string already present indicates fault in how the FileUrlGenerator is being used. T

    If the path has a query string on it that is not part of its on-disk filename that would be a problem in my opinion a streamWrapepr path of assets://foo.css?bar is not the same file as assets://foo.css and should not be treated as such.

    FileUrlGeneratorInterface::generateString()

       * @param string $uri
       *   The URI to a file for which we need an external URL, or the path to a
       *   shipped file.
       *
    

    Core currently uses $uri frequently to refer to public://foo/bar.txt or /foo/bar.txt as it relates to files, which has its own idiosyncrasies. In all these cases its pointing to a full path, in some cases this might be http/https links which are urlencoded() as that is actually a part of its filename to the system, in other cases, such as local disk its the raw filename where characters that would be special for URL's are actual literal filename characters.

    Realistically its impossible for the fileUrlGenerator to know when a request its receiving is urlencoded, or when the file actually contains those characters as part of the literal filename. This means the FileUrlGenerator needs to demand that file paths to it be always URL encoded, or never URL encoded it can't reliably have it both ways.

    We already have one bug with the FileUrlGenerator trying to urldecode() paths it receives from streamWrapeprs causing faults, see #3314663: File links for paths with reserved characters ( '+' & '#' '?') generated wrong for external streamWrappers. β†’ , deferring this to FileUrlGenerator is likely to cause another path where such an issue occurs.

  • πŸ‡¬πŸ‡§United Kingdom catch

    fwiw #2 is a better patch to look at for the change than #6 which is missing a hunk, but yeah I am starting to think this issue will not actually 'tidy up' but is more moving mess from one place to another.

Production build 0.71.5 2024