Skip to content

Commit

Permalink
[module:install] Remove moduleRequirement() (#4178)
Browse files Browse the repository at this point in the history
* Update services.yml

* Fix Travis tests

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* 1

* Ensure $roles is an array when creating users. (#4134)

This prevents an error from being thrown when constructing the success message.  See #4133.

* Generate revisional entity content is broken (#4139)

* Add bundle permissions for content entity (#4138)

* Add command option has-bundle-permissions and use on entity.

* Add (Entity}Permissions.php file.

* Add permission_callback to permissions.yml file.

* Added fix from #4139 as it hurts.

* Add own permissions checks.

* Add --default option to database:add (#4143)

This option allows to set the database as the default one instead of
adding a new database in addition to the default one.

See: #4142

* Update version to 1.9.3 (#4144)

* Update version to 1.9.3

* Remove Module/InstallCommand::moduleRequirement

* Remove
  • Loading branch information
mondrake authored and enzolutions committed Oct 10, 2019
1 parent 9af887a commit f82883c
Showing 1 changed file with 0 additions and 86 deletions.
86 changes: 0 additions & 86 deletions src/Command/Module/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->site->loadLegacyFile('/core/includes/bootstrap.inc');

// Check module's requirements, only for Drupal below 8.7.7. From there
// on, we just use Drupal's API.
if (version_compare(\Drupal::VERSION, '8.7.7') < 0) {
$this->moduleRequirement($module);
}

// When --composer is specified, build a command to Composer require
// all the needed modules in one go. This will just download the
// modules from the composer endpoint, not do any 'installation', in
Expand Down Expand Up @@ -274,84 +268,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->site->removeCachedServicesFile();
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}

/**
* Verify that install requirements for a list of modules are met.
*
* @param string[] $module
* List of modules to verify.
*
* @throws \Exception
* When one or more requirements are not met.
*/
public function moduleRequirement(array $module)
{
$modules_data = system_rebuild_module_data();

// for unmet requirements recursively.
$fail = false;
foreach ($module as $module_name) {
module_load_install($module_name);
if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', ['install'])) {
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$this->getIo()->errorLite("Module '{$module_name}' cannot be installed: {$requirement['title']} | {$requirement['value']}");
$this->getIo()->newLine();
$fail = true;
}
}
}

$module_data = $modules_data[$module_name];

// Check the core compatibility.
if ($module_data->info['core'] != \Drupal::CORE_COMPATIBILITY) {
$versionCore = \Drupal::CORE_COMPATIBILITY;
$this->getIo()->errorLite("This version is not compatible with Drupal {$versionCore} and should be replaced.");
$this->getIo()->newLine();
}

// Ensure this module is compatible with the currently installed version of PHP.
if (version_compare(phpversion(), $module_data->info['php']) < 0) {
$required = $module_data->info['php'] . (substr_count($module_data->info['php'], '.') < 2 ? '.*' : '');
$phpversion = phpversion();
$this->getIo()->errorLite("This module requires PHP version {$required} and is incompatible with PHP version {$phpversion}.");
$this->getIo()->newLine();
$fail = true;
}

// If this module requires other modules, add them to the array.
foreach ($module_data->requires as $dependency => $version) {
// dependency exist.
if (!isset($modules_data[$dependency])) {
$dependencyName = ucfirst($dependency);
$this->getIo()->errorLite("{$dependencyName} missing.");
$this->getIo()->newLine();
$fail = true;
}

elseif (empty($modules_data[$dependency]->hidden)) {
$name = $modules_data[$dependency]->info['name'];
// dependency's version.
if ($incompatible_version = drupal_check_incompatibility($version, str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules_data[$dependency]->info['version']))) {
$dependencyName = $name . $incompatible_version;
$dependencyVersion = $modules_data[$dependency]->info['version'];
$this->getIo()->errorLite("{$dependencyName} incompatible with version {$dependencyVersion}.");
$this->getIo()->newLine();
$fail = true;
}

// version of Drupal core.
elseif ($modules_data[$dependency]->info['core'] != \Drupal::CORE_COMPATIBILITY) {
$this->getIo()->errorLite("{$name} incompatible with this version of Drupal core.");
$this->getIo()->newLine();
$fail = true;
}
}
}
}
if ($fail) {
throw new \Exception('Some module install requirements are not met.');
}
}
}

0 comments on commit f82883c

Please sign in to comment.