Commit c5c1cdf6 authored by catch's avatar catch

Issue #2608408 by nlisgo, dagmar, aleevas, neclimdul, BR0kEN, gaydabura,...

Issue #2608408 by nlisgo, dagmar, aleevas, neclimdul, BR0kEN, gaydabura, pfrenssen, zuuperman: Call to a member function getPath() when installing Profiles with unknown modules as requirement
parent 83ddf6e2
......@@ -930,27 +930,35 @@ function drupal_requirements_url($severity) {
*/
function drupal_check_profile($profile) {
$info = install_profile_info($profile);
// Collect requirement testing results.
$requirements = array();
// Performs an ExtensionDiscovery scan as the system module is unavailable and
// we don't yet know where all the modules are located.
// @todo Remove as part of https://www.drupal.org/node/2186491
$listing = new ExtensionDiscovery(\Drupal::root());
$module_list = $listing->scan('module');
$drupal_root = \Drupal::root();
$module_list = (new ExtensionDiscovery($drupal_root))->scan('module');
foreach ($info['dependencies'] as $module) {
$file = \Drupal::root() . '/' . $module_list[$module]->getPath() . "/$module.install";
if (is_file($file)) {
require_once $file;
}
$function = $module . '_requirements';
// If the module is in the module list we know it exists and we can continue
// including and registering it.
// @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
if (isset($module_list[$module])) {
$function = $module . '_requirements';
$module_path = $module_list[$module]->getPath();
$install_file = "$drupal_root/$module_path/$module.install";
if (is_file($install_file)) {
require_once $install_file;
}
drupal_classloader_register($module, $module_path);
drupal_classloader_register($module, $module_list[$module]->getPath());
if (function_exists($function)) {
$requirements = array_merge($requirements, $function('install'));
if (function_exists($function)) {
$requirements = array_merge($requirements, $function('install'));
}
}
}
return $requirements;
}
......
<?php
namespace Drupal\Tests\system\Kernel\Installer;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that we handle the absence of a module dependency during install.
*
* @group Installer
*/
class InstallerMissingDependenciesTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Verifies that the exception message in the profile step is correct.
*/
public function testSetUpWithMissingDependencies() {
// Prime the drupal_get_filename() static cache with the location of the
// testing profile as it is not the currently active profile and we don't
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');
$info = drupal_verify_profile([
'parameters' => ['profile' => 'testing_missing_dependencies'],
'profile_info' => install_profile_info('testing_missing_dependencies'),
]);
$message = $info['required_modules']['description']->render();
$this->assertContains('Missing_module1', $message);
$this->assertContains('Missing_module2', $message);
}
}
name: 'Testing missing dependencies'
type: profile
description: 'Minimal profile for running a test when dependencies are listed but missing.'
version: VERSION
core: 8.x
hidden: true
dependencies:
- missing_module1
- missing_module2
keep_english: true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment