Problem/Motivation

When updating spamspan but not drupal/core, the JavaScript cache-busting parameter remains the same (e.g. ?v=10.4.8). When updating drupal/core but not spamspan, the JavaScript cache-busting parameter changes.
LibraryDiscoveryParser applies the Drupal version to every library that uses version: VERSION. It does not use the modules version.

See the note on Adding assets (CSS, JS) to a Drupal module via *.libraries.yml:

Starting from Drupal 10.1.2, the version information within a library definition plays a critical role in generating a unique hash for aggregated files. Consequently, it is imperative that the "version" in a library definition is updated whenever a referenced CSS/JS file undergoes changes.

Alternatively, if the version is omitted, the prior behavior will apply, where the content of referenced CSS/JS files is utilized in the hash.

Incorrect usage of version information could lead to browser and edge cache invalidation issues.

See this update on the related changelog.

Steps to reproduce

First case

  • Use spamspan 3.2.1, use drupal/core 10.4.8
  • Disable JS preprocessing
    $config['system.performance']['js']['preprocess'] = FALSE;
  • Enable spamspan filter for a text format
  • Create content with an email address
  • Look at site's source code and see
    <script src="/modules/contrib/spamspan/js/spamspan.js?v=10.4.8"></script>
  • Update spamspan to 3.2.2
  • Look at site's source code and see
    <script src="/modules/contrib/spamspan/js/spamspan.js?v=10.4.8"></script>

Second case

  • Use spamspan 3.2.2, use drupal/core 10.4.7
  • Disable JS preprocessing
    $config['system.performance']['js']['preprocess'] = FALSE;
  • Enable spamspan filter for a text format
  • Create content with an email address
  • Look at site's source code and see
    <script src="/modules/contrib/spamspan/js/spamspan.js?v=10.4.7"></script>
  • Update drupal/core to 10.4.8
  • Look at site's source code and see
    <script src="/modules/contrib/spamspan/js/spamspan.js?v=10.4.8"></script>

Proposed resolution

Remove version: VERSION from spamspan.libraries.yml

Issue fork spamspan-3542631

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hosterholz created an issue. See original summary.

hosterholz’s picture

Status: Active » Needs review
jannakha’s picture

Status: Needs review » Reviewed & tested by the community

thank you for your contribution!
MR looks good

  • anybody committed 100ea849 on 3.x authored by hosterholz
    Issue #3542631 by hosterholz: Do not use Drupal Core's version for...
anybody’s picture

Nice, thanks for the heads-up @hosterholz! Merged!

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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

anybody’s picture

Maybe a new release could be tagged?