Skip to content

Commit

Permalink
Unsupported modules now handles the case update module is not installed
Browse files Browse the repository at this point in the history
If update module is not installed an error message will be shown for the
specific environment. The final message have also changed to prevent
confussions in the output.
  • Loading branch information
omarlopesino committed May 30, 2023
1 parent 0e545c8 commit 2f5c2b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
9 changes: 9 additions & 0 deletions scripts/unsupported-modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

use Drupal\update\UpdateManagerInterface;

$module_handler = \Drupal::moduleHandler();

if (!$module_handler->moduleExists('update')) {
throw new Exception("Unable to report unsupported modules as Update module is not enabled in the site.");
}

$updateManager = \Drupal::service('update.manager');
$updateManager->refreshUpdateData();
$projectData = $updateManager->getProjects();
Expand Down Expand Up @@ -33,7 +39,10 @@

}
else {

$projects_unsupported_data = [];
}

print json_encode($projects_unsupported_data);


25 changes: 15 additions & 10 deletions src/UpdaterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,21 @@ protected function showObsoleteDrupalModules() {

$unsupported_modules_list = [];
foreach ($this->environments as $environment) {
$unsupported_modules = json_decode(trim($this
->runCommand(sprintf('drush %s php-script %s/../scripts/unsupported-modules.php', $environment, __DIR__))
->getOutput()));
foreach ($unsupported_modules as $unsupported_module) {
$unsupported_module = (array) $unsupported_module;
if (!isset($unsupported_modules_list[$unsupported_module['project_name']])) {
$unsupported_modules_list[$unsupported_module['project_name']] = $unsupported_module;
try {
$unsupported_modules = json_decode(trim($this
->runCommand(sprintf('drush %s php-script %s/../scripts/unsupported-modules.php', $environment, __DIR__))
->getOutput()));
foreach ($unsupported_modules as $unsupported_module) {
$unsupported_module = (array) $unsupported_module;
if (!isset($unsupported_modules_list[$unsupported_module['project_name']])) {
$unsupported_modules_list[$unsupported_module['project_name']] = $unsupported_module;
}
$unsupported_modules_list[$unsupported_module['project_name']]['environments'][] = $environment;
}
$unsupported_modules_list[$unsupported_module['project_name']]['environments'][] = $environment;
}
catch (ProcessFailedException $exception) {
$this->output->writeln('');
$this->output->write($exception->getMessage());
}
}

Expand All @@ -534,9 +540,8 @@ protected function showObsoleteDrupalModules() {
$fixed_drupal_advisories_table->render();
}
else {
$this->output->writeln('This project does not contain obsolete modules.');
$this->output->writeln('No obsolete modules have been found. Perhaps Update module is not installed?');
}

}

/**
Expand Down

0 comments on commit 2f5c2b0

Please sign in to comment.