Update Drupal::VERSION in dev branch

Created on 16 October 2024, 2 months ago

Currently 11.x branch define core version as 11.0-dev which is not correct.
This makes it hard for modules to adjust their behavior according to the Drupal core version.

For instance, I have to check Drupal version in tests because of some changes in Drupal 11.1. Currently failing because 11.x is recognized as 11.0.

\version_compare(\Drupal::VERSION, '11.1', '<')

Expected behavior
Drupal::VERSION to be set as 11.1-dev. Once Drupal 11.1 is released it should be updated to 11.2-dev.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

other

Created by

🇷🇺Russia Chi

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

Merge Requests

Comments & Activities

  • Issue created by @Chi
  • 🇷🇺Russia Chi

    I wonder if we really need to update the version manually. Can we fetch the version from Composer instead?

    Composer\InstalledVersions::getVersion('drupal/core')
    
  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Let's refocus this issue on the idea in #3 since we've got the original intention of this issue covered in 🐛 \Drupal::VERSION on 11.x not correct Active

    Note this is likely to be quite tricky because Composer is returning 11.1.9999999.9999999-dev for 11.1.x and 11.9999999.9999999.9999999-dev for 11.x - these version strings are correct BUT I'm pretty sure we have regex parsing of \Drupal::VERSION that assumes only major, minor, patch and I'm not sure that the regex patterns will cope with the fourth number. I think this is the internal representation - see https://getcomposer.org/doc/articles/versions.md#stability-constraints

  • 🇷🇺Russia Chi

    We may use getPrettyVersion() instead.

    echo Composer\InstalledVersions::getVersion('drupal/core'), \PHP_EOL;
    echo Composer\InstalledVersions::getPrettyVersion('drupal/core'), \PHP_EOL;
    

    Output on 10.3.10

    10.3.10.0
    10.3.10
    

    Output on 11.x

    11.9999999.9999999.9999999-dev
    11.x-dev
    
  • 🇷🇺Russia Chi

    Given that expressions are not allowed in class constants we will have to deprecate that constant in favor of static method.

    public static function version():string {
      return InstalledVersions::getPrettyVersion('drupal/core');
    }
    
  • First commit to issue fork.
  • Pipeline finished with Failed
    27 days ago
    Total: 135s
    #349456
  • 🇮🇳India arunkumark Coimbatore

    Created drafted MR as per the suggestion given by @chi in comments #7 and #8. The function getPrettyVersion() gives the proper version details.

  • 🇷🇺Russia Chi

    A bit surprised how much this constant is used in Drupal.

  • 🇬🇧United Kingdom oily Greater London

    @chi @arunkumark Is a change record required? Change record doc

  • 🇫🇷France andypost

    Surely it needs change record as method supposed to be introduced instead of constant

  • Pipeline finished with Failed
    26 days ago
    Total: 136s
    #349876
  • 🇳🇿New Zealand quietone

    Restoring standard template because it helps keep track of the work and it helps reviewers and committers.

  • Pipeline finished with Failed
    26 days ago
    Total: 134s
    #349916
  • Pipeline finished with Failed
    26 days ago
    Total: 157s
    #349927
  • Pipeline finished with Canceled
    26 days ago
    Total: 2054s
    #349938
  • Pipeline finished with Failed
    26 days ago
    Total: 138s
    #349954
  • 🇬🇧United Kingdom oily Greater London

    Work done on the 2x code comments.

    Deprecated the constant and added @deprecated to docblock.

    Pipeline error. Not sure how to fix.

  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom oily Greater London

    Tried to fix PHPSTAN in pipeline. There is no clear error message. Not sure if it is a defect in the pipeline or error(s) in the code.

  • Pipeline finished with Failed
    26 days ago
    Total: 8260s
    #349960
  • 🇮🇳India arunkumark Coimbatore

    Am also tried to resolve the PHPStan error, but could not solve it. Not sure if the stan error is because of a patch or something else.

  • 🇬🇧United Kingdom oily Greater London

    I am seeing this: "Merge blocked: 1 check failed". It states that the MR must not be draft (in order for the merge to be allowed).

  • Pipeline finished with Failed
    26 days ago
    Total: 3601s
    #350054
  • Pipeline finished with Canceled
    26 days ago
    Total: 154s
    #350367
  • Pipeline finished with Failed
    26 days ago
    Total: 230s
    #350370
  • Pipeline finished with Failed
    26 days ago
    Total: 180s
    #350425
  • Pipeline finished with Failed
    26 days ago
    Total: 141s
    #350453
  • Pipeline finished with Failed
    26 days ago
    Total: 136s
    #350504
  • 🇬🇧United Kingdom oily Greater London

    There are now several PHPSTAN errors mentioning deprecated constants. I tried to PHPSTAN ignore one of the errors but not working.

    Trying to figure out how to eliminate the remaining deprecation-related errors.

  • 🇬🇧United Kingdom oily Greater London

    Added change record.

    Currently stumped on eliminating deprecation related PHPSTAN errors.

    Changing to 'Needs review' hoping guidance on errors.

  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom joachim

    What's the performance cost?

    \Composer\InstalledVersions::getVersion() includes a file with 2000 lines of code in a monster array.

  • 🇷🇺Russia Chi

    It takes 0.015 ms on my localhost. That file is likely loaded from opcache and Composer caches the array in static variable. So it's Ok to call this method multiple times.

  • Pipeline finished with Failed
    25 days ago
    Total: 198s
    #351959
  • 🇺🇸United States dww
Production build 0.71.5 2024