Commit f13545c4 authored by memtkmcc's avatar memtkmcc

Issue #3149961: Improve packages and profiles handling

parent 3de1a9e8
......@@ -258,6 +258,8 @@ function _provision_find_profiles() {
if ($profile->name == 'standard') {
$profile->info['old_short_name'] = 'default';
}
$profile->info['old_short_name'] = isset($profile->info['old_short_name']) ? $profile->info['old_short_name'] : 'standard';
$profiles[$name] = $profile;
drush_log(dt('Found install profile %name', array('%name' => $name)));
......
......@@ -18,20 +18,27 @@ function _provision_drupal_find_themes($scope, $key = '') {
$files = array_merge($files, drush_scan_directory($path, "/\.info\.yml$/", array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name'));
$engines = array_merge($engines, drush_scan_directory($path . "/engines", "/\.engine$/", array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name'));
}
// Remove '.info' extension from the end of the file name.
foreach($files as $name => $file) {
$files[basename($name, '.info')] = $file;
unset($files[$name]);
}
foreach ($files as $name => $file) {
$files[$name]->info = Symfony\Component\Yaml\Yaml::parse(file_get_contents($file->filename));
if (!empty($files[$name]->info['name'])) {
$files[$name]->name = $files[$name]->info['name'];
}
if (!empty($files[$name]->info['version'])) {
$files[$name]->version = $files[$name]->info['version'];
}
// Resolve the 'VERSION' constant used in Git checkouts.
if ($files[$name]->version == 'VERSION') {
// If version is missing, or if version is set to 'VERSION', use "drush_drupal_version()".
// The VERSION constant used in Git checkouts. Also appears when using DEV modules in composer.
if (empty($files[$name]->info['version']) || !isset($files[$name]->version) || $files[$name]->version == 'VERSION') {
$files[$name]->version = drush_drupal_version();
}
else {
$files[$name]->version = $files[$name]->info['version'];
}
// @TODO: This is copied from the D7 implementation and I'm almost certain
// that is doesn't even do anything in D7.
......@@ -105,6 +112,7 @@ function _provision_system_query($type) {
foreach ($extensions_data as $name => $extension_data) {
$package = (object) $extension_data->info;
$package->filename = drupal_get_filename($type, $name);
$frags = explode("/", $package->filename);
// Flag site-specific packages.
if ($frags[0] == 'sites' && $frags[1] != 'all') {
......@@ -115,6 +123,23 @@ function _provision_system_query($type) {
if ($type == 'module') {
$package->schema_version = drupal_get_installed_schema_version($name);
if(!file_exists($package->filename)) {
drush_log(dt("@name.info.yml not found.", array("@name" => $name)), 'notice');
continue;
}
else {
$info = Symfony\Component\Yaml\Yaml::parse(file_get_contents($package->filename));
// Skip hidden modules
if (isset($info['hidden']) && $info['hidden'] != FALSE) {
continue;
}
// The 'drupal_get_filename()' function is returning at least one profile as a module
// (profile 'standard'). Make sure this is really a module. If not, skip it.
if (isset($info['type']) && $info['type'] != 'module') {
continue;
}
}
}
$packages[$name] = $package;
......
......@@ -581,9 +581,23 @@ function provision_drupal_system_map() {
function _provision_drupal_find_modules($scope, $key = '') {
$paths = _provision_drupal_search_paths($scope, $key, 'modules');
$files = array();
foreach ($paths as $path) {
$files = array_merge($files, drush_scan_directory($path, "/\.module$/", array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name'));
if (drush_drupal_major_version() >= 8) {
foreach ($paths as $path) {
$files = array_merge($files, drush_scan_directory($path, "/\.info\.yml$/", array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name'));
}
// Remove '.info' extension from the end of the file name.
foreach($files as $name => $file) {
$files[basename($name, '.info')] = $file;
unset($files[$name]);
}
}
else {
foreach ($paths as $path) {
$files = array_merge($files, drush_scan_directory($path, "/\.module$/", array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name'));
}
}
foreach ($files as $name => $info) {
if (drush_drupal_major_version() >= 8) {
$yaml_file = sprintf("%s/%s.info.yml", dirname($info->filename), $name);
......@@ -616,6 +630,11 @@ function _provision_drupal_find_modules($scope, $key = '') {
}
if (file_exists($install_file)) {
$source = file_get_contents(trim($install_file));
// Some modules keep update hooks in an include file (webform).
$install_file_include = sprintf("%s/includes/%s.install.update.inc", dirname($info->filename), $name);
if (file_exists($install_file_include)) {
$source .= "\n" . file_get_contents(trim($install_file_include));
}
$source = str_replace("\r\n", "\n", $source);
$source = str_replace("\r", "\n", $source);
// Also search included files for function signature
......@@ -636,13 +655,15 @@ function _provision_drupal_find_modules($scope, $key = '') {
}
}
$files[$name]->schema_version = $schema_version;
$files[$name]->version = $files[$name]->info['version'];
// Resolve the 'VERSION' constant used in Git checkouts.
if ($files[$name]->version == 'VERSION') {
// If version is missing, or if version is set to 'VERSION', use "drush_drupal_version()".
// The VERSION constant used in Git checkouts. Also appears when using DEV modules in composer.
if (empty($files[$name]->info['version']) || !isset($files[$name]->version) || $files[$name]->version == 'VERSION') {
$files[$name]->version = drush_drupal_version();
}
else {
$files[$name]->version = $files[$name]->info['version'];
}
}
return $files;
}
......
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