Skip to content
Snippets Groups Projects
Commit e04ddbc4 authored by Theresa Grannum's avatar Theresa Grannum Committed by Ted Bowman
Browse files

Issue #3303929 by Theresa.Grannum: Never allow updating to an un-installable version

parent 77b86bc8
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ use Drupal\Core\State\StateInterface; ...@@ -13,6 +13,7 @@ use Drupal\Core\State\StateInterface;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\package_manager\ProjectInfo;
use Drupal\system\SystemManager; use Drupal\system\SystemManager;
use Drupal\update\UpdateManagerInterface; use Drupal\update\UpdateManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -241,22 +242,24 @@ final class UpdaterForm extends FormBase { ...@@ -241,22 +242,24 @@ final class UpdaterForm extends FormBase {
return []; return [];
} }
$project_data = update_calculate_project_data($available_updates); $all_projects_data = update_calculate_project_data($available_updates);
$outdated_modules = []; $outdated_modules = [];
$installed_packages = array_keys($this->extensionUpdater->getActiveComposer()->getInstalledPackages()); $installed_packages = array_keys($this->extensionUpdater->getActiveComposer()->getInstalledPackages());
$non_supported_update_statuses = []; $non_supported_update_statuses = [];
foreach ($project_data as $project_name => $project_info) { foreach ($all_projects_data as $project_name => $project_data) {
if (in_array($project_info['project_type'], $supported_project_types, TRUE)) { if (in_array($project_data['project_type'], $supported_project_types, TRUE)) {
if ($project_info['status'] !== UpdateManagerInterface::CURRENT) { if ($project_data['status'] !== UpdateManagerInterface::CURRENT) {
if (!in_array("drupal/$project_name", $installed_packages, TRUE)) { if (!in_array("drupal/$project_name", $installed_packages, TRUE)) {
$non_supported_update_statuses[] = $project_info['status']; $non_supported_update_statuses[] = $project_data['status'];
continue; continue;
} }
if (!empty($project_info['recommended'])) { $project_information = new ProjectInfo($project_name);
$outdated_modules[$project_name] = $project_info; $installable_versions = array_keys($project_information->getInstallableReleases());
if (!empty($project_data['recommended']) && in_array($project_data['recommended'], $installable_versions, TRUE)) {
$outdated_modules[$project_name] = $project_data;
} }
else { else {
$non_supported_update_statuses[] = $project_info['status']; $non_supported_update_statuses[] = $project_data['status'];
} }
} }
} }
...@@ -287,7 +290,6 @@ final class UpdaterForm extends FormBase { ...@@ -287,7 +290,6 @@ final class UpdaterForm extends FormBase {
$message_status $message_status
); );
} }
} }
return $outdated_modules; return $outdated_modules;
} }
......
name: 'Automatic Updates Extensions Tests'
description: 'Provides functional tests for recommended versions'
type: module
package: Testing
dependencies:
- automatic_updates:automatic_updates_extensions
<?php
/**
* @file
* Contains hook implementation for Automatic Updates Extensions Test.
*/
/**
* Implements hook_update_status_alter().
*/
function automatic_updates_extensions_test_update_status_alter(&$projects) {
if (\Drupal::state()->get('testUninstallableRelease') && !empty($projects['semver_test'])) {
$projects['semver_test']['recommended'] = $projects['semver_test']['existing_version'];
}
}
...@@ -38,6 +38,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -38,6 +38,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
'block', 'block',
'semver_test', 'semver_test',
'aaa_update_test', 'aaa_update_test',
'automatic_updates_extensions_test',
]; ];
/** /**
...@@ -416,4 +417,19 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -416,4 +417,19 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$assert->buttonExists('Update'); $assert->buttonExists('Update');
} }
/**
* Tests the form when an uninstallable module requires an update.
*/
public function testUninstallableRelease(): void {
$this->container->get('state')->set('testUninstallableRelease', TRUE);
$this->setReleaseMetadata(__DIR__ . '/../../fixtures/release-history/semver_test.1.1.xml');
$assert = $this->assertSession();
$this->setProjectInstalledVersion(['semver_test' => '8.1.0']);
$user = $this->createUser(['administer software updates', 'administer site configuration']);
$this->drupalLogin($user);
$this->drupalGet('admin/reports/updates/automatic-update-extensions');
$this->checkForUpdates();
$this->assertNoUpdates();
}
} }
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