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
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\automatic_updates_extensions; namespace Drupal\automatic_updates_extensions;
use Drupal\automatic_updates\Exception\UpdateException; use Drupal\automatic_updates\Exception\UpdateException;
use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\Event\StageEvent;
use Drupal\package_manager\Exception\StageValidationException; use Drupal\package_manager\Exception\StageValidationException;
use Drupal\package_manager\Stage; use Drupal\package_manager\Stage;
......
...@@ -4,7 +4,7 @@ namespace Drupal\automatic_updates_extensions\Validator; ...@@ -4,7 +4,7 @@ namespace Drupal\automatic_updates_extensions\Validator;
use Drupal\automatic_updates\ProjectInfo; use Drupal\automatic_updates\ProjectInfo;
use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\automatic_updates_extensions\LegacyVersionUtility; use Drupal\automatic_updates\LegacyVersionUtility;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\package_manager\Event\PreCreateEvent; use Drupal\package_manager\Event\PreCreateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Tests\automatic_updates_extensions\Kernel\Valdiator; 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\Event\PreCreateEvent;
use Drupal\package_manager\ValidationResult; use Drupal\package_manager\ValidationResult;
use Drupal\Tests\automatic_updates_extensions\Kernel\AutomaticUpdatesExtensionsKernelTestBase; use Drupal\Tests\automatic_updates_extensions\Kernel\AutomaticUpdatesExtensionsKernelTestBase;
......
<?php <?php
namespace Drupal\automatic_updates_extensions; namespace Drupal\automatic_updates;
use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Extension\ExtensionVersion;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\automatic_updates; namespace Drupal\automatic_updates;
use Composer\Semver\Comparator;
use Drupal\automatic_updates_9_3_shim\ProjectRelease; use Drupal\automatic_updates_9_3_shim\ProjectRelease;
use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\Extension\ExtensionVersion;
use Drupal\update\UpdateManagerInterface; use Drupal\update\UpdateManagerInterface;
...@@ -115,7 +116,9 @@ class ProjectInfo { ...@@ -115,7 +116,9 @@ class ProjectInfo {
foreach ($available_updates['releases'] as $release_info) { foreach ($available_updates['releases'] as $release_info) {
$release = ProjectRelease::createFromArray($release_info); $release = ProjectRelease::createFromArray($release_info);
$version = $release->getVersion(); $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. // Stop searching for releases as soon as we find the installed version.
break; break;
} }
......
...@@ -94,5 +94,29 @@ ...@@ -94,5 +94,29 @@
<term><name>Release type</name><value>Bug fixes</value></term> <term><name>Release type</name><value>Bug fixes</value></term>
</terms> </terms>
</release> </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> </releases>
</project> </project>
...@@ -104,6 +104,16 @@ class ProjectInfoTest extends AutomaticUpdatesKernelTestBase { ...@@ -104,6 +104,16 @@ class ProjectInfoTest extends AutomaticUpdatesKernelTestBase {
'8.x-6.1', '8.x-6.1',
['7.0.1', '7.0.0', '7.0.0-alpha1', '8.x-6.2'], ['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 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation;
use Drupal\automatic_updates\CronUpdater;
use Drupal\package_manager\ValidationResult; use Drupal\package_manager\ValidationResult;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
...@@ -22,6 +23,11 @@ class InstalledVersionValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -22,6 +23,11 @@ class InstalledVersionValidatorTest extends AutomaticUpdatesKernelTestBase {
*/ */
public function testInstalledVersionValidation(): void { public function testInstalledVersionValidation(): void {
$this->setCoreVersion('9.8.0-dev'); $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([ $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.', '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 <?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; 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 { class LegacyVersionUtilityTest extends UnitTestCase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment