Skip to content
Snippets Groups Projects
Commit dae56200 authored by Ted Bowman's avatar Ted Bowman Committed by Adam G-H
Browse files

Issue #3279733 by tedbow:...

Issue #3279733 by tedbow: \Drupal\automatic_updates\ProjectInfo::getInstallableReleases() will return releases lower than the installed version if the installed version is a dev release
parent 0c7571d2
No related branches found
No related tags found
1 merge request!314Issue #3279733: \Drupal\automatic_updates\ProjectInfo::getInstallableReleases() will return releases lower than the installed version if the installed version is a dev release
......@@ -3,6 +3,7 @@
namespace Drupal\automatic_updates_extensions;
use Drupal\automatic_updates\Exception\UpdateException;
use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\package_manager\Event\StageEvent;
use Drupal\package_manager\Exception\StageValidationException;
use Drupal\package_manager\Stage;
......
......@@ -4,7 +4,7 @@ namespace Drupal\automatic_updates_extensions\Validator;
use Drupal\automatic_updates\ProjectInfo;
use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\automatic_updates_extensions\LegacyVersionUtility;
use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\package_manager\Event\PreCreateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......
......@@ -2,7 +2,7 @@
namespace Drupal\Tests\automatic_updates_extensions\Kernel\Valdiator;
use Drupal\automatic_updates_extensions\LegacyVersionUtility;
use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\ValidationResult;
use Drupal\Tests\automatic_updates_extensions\Kernel\AutomaticUpdatesExtensionsKernelTestBase;
......
<?php
namespace Drupal\automatic_updates_extensions;
namespace Drupal\automatic_updates;
use Drupal\Core\Extension\ExtensionVersion;
......
......@@ -2,6 +2,7 @@
namespace Drupal\automatic_updates;
use Composer\Semver\Comparator;
use Drupal\automatic_updates_9_3_shim\ProjectRelease;
use Drupal\Core\Extension\ExtensionVersion;
use Drupal\update\UpdateManagerInterface;
......@@ -115,7 +116,9 @@ class ProjectInfo {
foreach ($available_updates['releases'] as $release_info) {
$release = ProjectRelease::createFromArray($release_info);
$version = $release->getVersion();
if ($version === $installed_version) {
$semantic_version = LegacyVersionUtility::convertToSemanticVersion($version);
$semantic_installed_version = LegacyVersionUtility::convertToSemanticVersion($installed_version);
if (Comparator::lessThanOrEqualTo($semantic_version, $semantic_installed_version)) {
// Stop searching for releases as soon as we find the installed version.
break;
}
......
......@@ -94,5 +94,29 @@
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
<release>
<name>AAA 7.0.0-dev</name>
<version>7.0.x-dev</version>
<status>published</status>
<release_link>http://example.com/aaa_automatic_updates_test-9-7-0-dev-release</release_link>
<download_link>http://example.com/aaa_automatic_updates_test-9-7-0-dev.tar.gz</download_link>
<date>1250424521</date>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
<release>
<name>AAA 8.x-6.x-dev</name>
<version>8.x-6.x-dev</version>
<status>published</status>
<release_link>http://example.com/aaa_automatic_updates_test-9-8-0-dev-release</release_link>
<download_link>http://example.com/aaa_automatic_updates_test-9-8-0-dev.tar.gz</download_link>
<date>1250424521</date>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
</releases>
</project>
......@@ -104,6 +104,16 @@ class ProjectInfoTest extends AutomaticUpdatesKernelTestBase {
'8.x-6.1',
['7.0.1', '7.0.0', '7.0.0-alpha1', '8.x-6.2'],
],
'contrib, semver and legacy, on semantic dev' => [
'aaa_automatic_updates_test.9.8.2.xml',
'7.0.x-dev',
['7.0.1', '7.0.0', '7.0.0-alpha1'],
],
'contrib, semver and legacy, on legacy dev' => [
'aaa_automatic_updates_test.9.8.2.xml',
'8.x-6.x-dev',
['7.0.1', '7.0.0', '7.0.0-alpha1', '8.x-6.2', '8.x-6.1', '8.x-6.0', '8.x-6.0-alpha1'],
],
];
}
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation;
use Drupal\automatic_updates\CronUpdater;
use Drupal\package_manager\ValidationResult;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
......@@ -22,6 +23,11 @@ class InstalledVersionValidatorTest extends AutomaticUpdatesKernelTestBase {
*/
public function testInstalledVersionValidation(): void {
$this->setCoreVersion('9.8.0-dev');
// Disable cron to avoid messages from other validators.
// @see \Drupal\automatic_updates\Validator\CronUpdateVersionValidator
$this->config('automatic_updates.settings')
->set('cron', CronUpdater::DISABLED)
->save();
$result = ValidationResult::createError([
'Drupal cannot be automatically updated from the installed version, 9.8.0-dev, because automatic updates from a dev version to any other version are not supported.',
......
<?php
namespace Drupal\Tests\automatic_updates_extensions\Unit;
namespace Drupal\Tests\automatic_updates\Unit;
use Drupal\automatic_updates_extensions\LegacyVersionUtility;
use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\automatic_updates_extensions\LegacyVersionUtility
* @coversDefaultClass \Drupal\automatic_updates\LegacyVersionUtility
*
* @group automatic_updates_extensions
* @group automatic_updates
*/
class LegacyVersionUtilityTest extends UnitTestCase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment