Problem/Motivation

  1. Only core modules are able to specify version: VERSION in their declared libraries, because the version of a core module is the version of Drupal core.
  2. In case a module or theme is updated, then the version query string that is appended to the library asset files on output will not reflect the new version.
  3. The version of a non-core module has to be retrieved from the extension system.

This may or may not be resolved by #2203411: Convert drupal_get_library() into a service, so tracking as an independent issue to be sure that we will resolve it.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-2205027

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

jibran’s picture

What is the status of this issue now?

wim leers’s picture

Assigned: Unassigned » nod_

I think/hope nod_ has some thoughts about this. IIRC he was the one who pioneered that VERSION constant, and deferred this problem to later.

nod_’s picture

Assigned: nod_ » Unassigned

Don't remember that I introduced it but VERSION should default to the module version in contrib and core version for core stuff. I think we agree on what the behavior is and need to have the code written for that to work.

wim leers’s picture

Priority: Normal » Major

That's indeed exactly what I expected. Thanks for confirming :)

This seems at least major, because if we don't fix this, some modules may run into problems. OTOH, this shouldn't break anything, nor should it require API changes.

gapple’s picture

Version: 8.0.x-dev » 8.1.x-dev
StatusFileSize
new3.3 KB

This patch parses the extension's info file to determine version.

If the info file doesn't include a version declaration (e.g. git checkouts directly from source), it will fall back to the version of core. Not sure if there's a better fallback alternative here?

gapple’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: drupal-2205027-5-library-VERSION.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gapple’s picture

Status: Needs work » Needs review
StatusFileSize
new8.66 KB

A re-roll, and apparently I had some tests already in progress locally.

gapple’s picture

StatusFileSize
new9.05 KB

Handle non-core, non-active themes properly.

Status: Needs review » Needs work

The last submitted patch, 10: drupal-2205027-10-library-VERSION.patch, failed testing.

gapple’s picture

Status: Needs work » Needs review
StatusFileSize
new13.37 KB

- Fixed handling of core modules (extension is in core/modules, core/themes/, or *.info.yml contains 'version: VERSION')
- Separate tests to check module and theme version handling

Status: Needs review » Needs work

The last submitted patch, 12: drupal-2205027-12-library-VERSION.patch, failed testing.

gapple’s picture

Status: Needs work » Needs review
StatusFileSize
new13.37 KB

Fixed syntax errors

Status: Needs review » Needs work

The last submitted patch, 14: drupal-2205027-14-library-VERSION.patch, failed testing.

gapple’s picture

Status: Needs work » Needs review
StatusFileSize
new13.48 KB

Some refactoring & fixes to tests (now passing locally)

dawehner’s picture

IMHO this is not a bug, but rather how this constant is meant to be used. It is just for the core version.

\Drupal\Core\Extension\InfoParserDynamic::parse has the same kind of logic as the library parser has at the moment. In order for your changes to be useful though we would also somehow take into account git/composer etc.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gapple’s picture

StatusFileSize
new12.38 KB

I continue to see new D8 modules and themes using version: VERSION as a default, without understanding that it resolves to the version of core.

Update patch for 8.5

Status: Needs review » Needs work

The last submitted patch, 21: drupal-2205027-21-library-VERSION.patch, failed testing. View results

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

jwilson3’s picture

The fallback logic for the version string added to libraries would be more robust if we were to also include custom values of the deployment_identifier setting in settings.php, and only if deployment_identifier is empty, fall back to \Drupal::VERSION.

In a typical scenario, an automated release procedure bumps the deployment_identifier in settings.php to a specific release number and then all minified/externally preprocessed assets in libraries.yml that don't define their own version would use this instead of \Drupal::VERSION, for improved cache-busting purposes.

Without the deployment_identifier the deployment script must search through all custom modules and either bump the version number in the info.yml and use this patch, or bump versions of specific libraries with externally compressed files that should be excluded from Drupal JS aggregation. Otherwise, the developer is required to bump the version string manually any time a change is made to the files and they're recompressed -- which in reality happens several times a day on each commit/change.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -99,9 +121,26 @@ public function buildByExtension($extension) {
+            if ($extension_type === 'theme') {
+              $extension_info_path = $this->themeHandler->getTheme($extension)->getPathname();
+            }
+            else {
+              $extension_info_path = $this->moduleHandler->getModule($extension)->getPathname();
+            }
+
+            $info = $this->infoParser->parse($extension_info_path);
+            if (!empty($info['version'])) {

this shouldn't be parsing the extension, it should instead use the various extension list services.

Other than that, this looks like a nice improvement.

I'm not sure this should be classed as a bug though, more of a feature request or task.

Triaged it as part of Bug Smash Initiative.

Going to move it to a task. Feel free to counter with alternate reasoning as to why its a bug.

@dawehner above also agreed with me re the Bug classification

Parsing it ourself here bypasses hook_system_info_alter and is also less performant.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dqd’s picture

Haven't read yet over all comments but found parallel thoughts of what brought me here in my mind matching the initial issue summary point 1.) and comment #3 or nod_ while I was fixing library.yml version issues in contrib modules.

What if we simply use the module version created by packaging script as /?version-path-suffix for library files and deprecate the tag for library files completely? Is that possible? It would be a quick solution at least ... (Drawback: no manual override possible then. But for what should that be needed? And!-> git installations would be out of scope... maybe a deal breaker)

jrglasgow made their first commit to this issue’s fork.

nicodh’s picture

StatusFileSize
new15.01 KB

Hi,
I've rerolled the patch in #21 with #31 suggestions, with Drupal 10.4.x

nicodh’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Have not reviewed but change should be in an MR.

prem suthar made their first commit to this issue’s fork.

prem suthar’s picture

Added the Mr with the Drupal 11 version with the some code updates and Added Mr Form Patch #38 as per the suggestion of 40 .

quietone’s picture

Issue summary: View changes

added template to help with the issue summary update.

prem suthar’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.