Problem/Motivation

discovered in #3074993: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates

In above issue #3105463: Create tests for recommended bugfix releases was split out to create missing test coverage. Test coverage was added for contrib but for core there is bug that could happen in a very special case. This likely to never happen in core releases but that same problem could happen contrib during #3009338: [META] Support semantic versioning for extensions (modules, themes, etc) in Drupal core, and allow modules to be compatible with Drupal 8 and 9 at the same time

In update_calculate_project_update_status() docblock there is explanation of how recommended releases are determined.

*
 * - 1.6-bugfix <-- recommended version because 1.6 already exists.
 * - 1.6
 *
 * or
 *
 * - 1.6-beta
 * - 1.5 <-- recommended version because no 1.6 exists.
 * - 1.4
 *

In the example there is not special logic around the "bugfix" string just the extra string and whether the regular version comes before or after the version without the extra string at the end.

The code related to this works for 8.x-1.0 style projects

    // Look for the 'recommended' version if we haven't found it yet (see
    // phpdoc at the top of this function for the definition).
    if (!isset($project_data['recommended'])
        && $release['version_major'] == $target_major
        && isset($release['version_patch'])) {
      if ($patch != $release['version_patch']) {
        $patch = $release['version_patch'];
        $release_patch_changed = $release;
      }
      if (empty($release['version_extra']) && $patch == $release['version_patch']) {
        $project_data['recommended'] = $release_patch_changed['version'];
        $project_data['releases'][$release_patch_changed['version']] = $release_patch_changed;
      }
    }

But in the case where project with semantic version releases like so:

1.2.0-alpha
1.1.0
1.0.0
1.0.0-alpha

If the site is currently on 1.0.0 the recommended release should be 1.1.0. But actually 1.2.0-alpha will be recommended.

This because the code above assumes there will be no minor releases and that there won't be 2 releases with the same minor.

The reason we don't see this problem currently in core is that the above release would not happen. If the releases were instead

1.2.0-alpha
1.1.1 // New release no in example above
1.1.0
1.0.0
1.0.0-alpha

Then 1.1.1 would be recommended which is correct.

The bug only happens when you release in order where the first is pre-release and the next is stable release for the previous minor with the same patch number.. Because this situation doesn't happen in core we don't see the problem.

This could happen in contrib after #3009338: [META] Support semantic versioning for extensions (modules, themes, etc) in Drupal core, and allow modules to be compatible with Drupal 8 and 9 at the same time.

Proposed resolution

The current patch in #3074993-82: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates has a fix for this problem because it takes into account the whole version number extra the "extra" part.

We should confirm it is fixed and add tests in #3100386: Create contrib update module test cases that use semantic versioning

If it is fixed we can just close this issue.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3105492-2.patch3.53 KBtedbow

Issue fork drupal-3105492

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

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
StatusFileSize
new3.53 KB

Here is a quick patch to demonstrate the fail

  1. updates core/modules/update/tests/modules/update_test/drupal.1.1.xml to add 8.2.1-alpha1 release.
    This test should still recommend 8.1.1 because it should not release with "extra" version number unless it comes after 8.2.1. But because 8.1.1 and 8.2.1-alpha1 have the same patch release it will be confused for a "Bugfix" type of release for 8.1.1.

    The test should fail on

    $this->assertVersionUpdateLinks('Recommended version:', $full_version);
    

    on line 128.

Status: Needs review » Needs work

The last submitted patch, 2: 3105492-2.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review

the test failure was expected

xjm’s picture

Title: An pre-release update will be recommend for semantic version updates if the patch number is the same latest from previous release » A pre-release update will be recommend for semantic version updates if the patch number is the same latest from previous release
dww’s picture

Haven't looked closely, but I don't think #3111929 would solve this, since that was specifically on the question of supported_branches, which doesn't impact the bug described here. #2 is a drupalci.yml'ed fail-only, so it's almost free to requeue. Doing that now. I suspect it'll still fail. Note: I don't immediately understand *why* #2 fails, thanks to #3115435: Make clear why each XML update.module fixture is created the way it is not being done. ;) It just adds another release to a fixture, but I'd have to dig deeper to fully comprehend the change.

avpaderno’s picture

Title: A pre-release update will be recommend for semantic version updates if the patch number is the same latest from previous release » A pre-release update will be recommended for semantic version updates if the patch number is equal to the patch number from the previous release
dww’s picture

Heh, I tried to reroll this. #3111929 didn't fix the bug, but it sure made getting the test-only case harder. ;) #2 doesn't apply since this same fixture is now used to test that we don't recommend a 8.2.0 release from an unsupported branch. So it'll be more work to get a test-only again in here, and I don't have time to do that right now. Sorry.

dww’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

'Active' might be more appropriate here. We have to start over from scratch on the fail-only patch, and there's no solution patch even started. But let's call it NW, I guess. ;)

xjm’s picture

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

Since this is a bug, it's probably eligible for backport in a patch release (unless we find something disruptive is required to fix it).

xjm’s picture

Issue tags: +beta target

Also a potential beta target as a bug related to the new semver functionality, although the bug is not as serious as others.

tim.plunkett’s picture

Issue tags: -beta target

Still a bug, but untagging as a beta target per a discussion with @xjm and @tedbow.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

tedbow’s picture

Issue summary: View changes

I think the next step here to turn this into a Merge Request.

Basically all #2 did was add a release to 1 of our test fixtures. This release should not have been recommended and test should still have passed because the site was on a stable non-alpha release the new release added was an alpha.
But test failed which shows the problem.

The tests and the test fixtures have been refactored since this patch was made.

the new test method that this should affect is \Drupal\Tests\update\Functional\UpdateSemverTestBase::testNoUpdatesAvailable().

The new fixture is core/modules/update/tests/fixtures/release-history/drupal.1.1.xml but I think there will be a problem with using this because in the previous patch I was adding a Drupal 8.2.1-alpha1 release which should have been ignored. but now in #3111929: If no recommended update is found, Update Status recommends the latest release, even if it is unsupported we added a Drupal 8.2.0 which is ignored because supported_branches doesn't have 8.2.. So adding Drupal 8.2.1-alpha1 will no longer work to show the bug because it will be ignored because the branch is not supported not because it is an alpha, which is what this issue is trying to prove.

One idea for updating the fixtures:

You can see in the XML fixtures many have <!-- This release is not in a supported branch; therefore it should not be recommended. -->. This is for the 8.2.0 release and 8.2. branch so we can't use that one. We could change all of these fixture to use 8.3.0 release and 8.3. as the unsupported branch.

This would allow use to add a Drupal 8.2.1-alpha1 release and add 8.2. as support branch. In this case Drupal 8.2.1-alpha1 should not be recommended but I think it will because the test is broken.

My advice would be to locally change only 1 fixture currently, for example core/modules/update/tests/fixtures/release-history/drupal.1.1.xml and change the loops in \Drupal\Tests\update\Functional\UpdateSemverTestBase::testNoUpdatesAvailable() to only use this fixture to see if this actually works to prove the bug.

tedbow’s picture

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

This should be fixed in 9.3.x first

I chatted with @kunal.sachdev and he was going to give it a try when he has time

kunal.sachdev made their first commit to this issue’s fork.

tedbow’s picture

Category: Bug report » Task

So I think this bug was actually fixed. If you look that code in the summary

 // Look for the 'recommended' version if we haven't found it yet (see
    // phpdoc at the top of this function for the definition).
    if (!isset($project_data['recommended'])
        && $release['version_major'] == $target_major
        && isset($release['version_patch'])) {
      if ($patch != $release['version_patch']) {
        $patch = $release['version_patch'];
        $release_patch_changed = $release;
      }
      if (empty($release['version_extra']) && $patch == $release['version_patch']) {
        $project_data['recommended'] = $release_patch_changed['version'];
        $project_data['releases'][$release_patch_changed['version']] = $release_patch_changed;
      }
    }

This has been changed a lot. This was fixed in #3074993: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates. We use to only care if the patch number had changed so if we had a new version number that had the same major and the same patch then the bug would happen.

Now we have


if ($recommended_version_without_extra !== $release_version_without_extra) {
        $recommended_version_without_extra = $release_version_without_extra;
        $recommended_release = $release_info;
      }

So we are looking at major, minor and patch. So the new will pick up the difference between 8.1.1 and 8.2.1. In the old code, the "2" for the minor would be ignored.

So we could add my suggestion in #14 as a way to prove this is not longer a problem and that the minor version is not ignored. We would also have to update the contrib version of the fixture and update the test to check that 8.2.1-alpha1 is not recommend but it is shown as the "Latest release"

changing this from a "Bug report" to a "Task" as this issue is not about hardening the test coverage not fixing a bug.

tedbow’s picture

Status: Needs work » Needs review

Sorry, I work with @kunal.sachdev for the test changes in the branch 3105492-a-pre-release-update but I forgot how complicated it is changing XML files because they are used by multiple tests.

I create a new test only for this specific case. I think the problem is basically a minor, in the test 8.1.0, which does not have any other patch releases, ie 8.1.1 is never released. If this happens and the next minors non-stable release are released, in the test 8.2.0-alpha1 then the only bug would have recommended 8.2.0-alpha1. It should be only listed as "Lasted"

The bug is actually fixed for the reason I explained in #17 but we still need a test to prove it and make sure the bug is not reintroduced.

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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Removing the tests tag as I see them in MR1463
Can the MR be updated for 10.1 please.
The open threads were those just comments you had or changes that are needed?

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.

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.