serve_js and serve_css have undocumented assumption

Created on 22 May 2019, almost 6 years ago
Updated 9 August 2023, almost 2 years ago

Problem/Motivation

Typically, however, many site builders will create the flysystem definitions in order of importance. Typically, something like S3 first, then something like local last. This poses no complication to the module until you use serve_js and serve_css.

In SchemeExtensionTrait, flysystem definitions are read in order, and the last definition wins:

  public function getSchemeForExtension($extension) {

    $extension_scheme = 'public';

    foreach (Settings::get('flysystem', []) as $scheme => $configuration) {
      if (!empty($configuration['serve_' . $extension]) && !empty($configuration['driver'])) {
        // Don't break, the last configured one will win.
        $extension_scheme = $scheme;
      }
    }

    return $extension_scheme;
  }

There is no mention of this behavior in the README, so an unwary developer may apply the serve_* options to all flysystem definitions. This, combined with the above priority order for writing definitions results in much unnecessary headdesking.

Proposed resolution

Update the documentation to specifically and loudly point out that serve_js and serve_css should only be applied to one definition, and never multiple definitions.

Remaining tasks

Create patch for README.md.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Updated README.md with clarifying instructions for serving CSS and JS assets.

πŸ› Bug report
Status

Fixed

Version

2.1

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States socketwench

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.

Production build 0.71.5 2024