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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3105492-2.patch | 3.53 KB | tedbow |
Issue fork drupal-3105492
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
Comment #2
tedbowHere is a quick patch to demonstrate the fail
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
on line 128.
Comment #4
tedbowthe test failure was expected
Comment #5
xjmDid #3111929: If no recommended update is found, Update Status recommends the latest release, even if it is unsupported address this issue, or is there still a bug?
Comment #6
dwwHaven'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.
Comment #7
avpadernoComment #8
dwwHeh, 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.
Comment #9
dww'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. ;)
Comment #10
xjmSince this is a bug, it's probably eligible for backport in a patch release (unless we find something disruptive is required to fix it).
Comment #11
xjmAlso a potential beta target as a bug related to the new semver functionality, although the bug is not as serious as others.
Comment #12
tim.plunkettStill a bug, but untagging as a beta target per a discussion with @xjm and @tedbow.
Comment #14
tedbowI 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.xmlbut I think there will be a problem with using this because in the previous patch I was adding aDrupal 8.2.1-alpha1release 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 aDrupal 8.2.0which is ignored becausesupported_branchesdoesn't have 8.2.. So addingDrupal 8.2.1-alpha1will 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-alpha1release and add 8.2. as support branch. In this caseDrupal 8.2.1-alpha1should 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.xmland 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.Comment #15
tedbowThis 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
Comment #17
tedbowSo I think this bug was actually fixed. If you look that code in the summary
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
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-alpha1is 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.
Comment #20
tedbowSorry, 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.
Comment #24
smustgrave commentedThis 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?