Skip to content

Commit

Permalink
Issue #382: Fix failure to check core submodule dependencies (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkshire-pudding authored May 23, 2024
1 parent c457b06 commit a26e570
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ and this project follows the
### Changed
- Updated Lando file to reflect Lando v3.21.0.
- Lando dev/testing recipe updated to allow to switch bee version with rebuild.
### Fixed
### Fixed
- GitHub Action tests failing.
- Warning if database settings in array and port not included.
- Failure to find existing core submodule dependencies.

### [1.x-1.0.1] - 2024-04-24

Expand Down
36 changes: 21 additions & 15 deletions commands/download.bee.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,23 @@ function download_bee_callback($arguments, $options) {

// Get list of all core projects so we don't try to download core dependencies
// when we download a named project.
$core_project_list = array();
if (!empty($_bee_backdrop_root)) {
// Look in folders for core modules, themes and layouts.
$project_types = array('module', 'theme', 'layout');
foreach ($project_types as $project_type) {
$core_project_path = "{$_bee_backdrop_root}/core/{$project_type}s";
$core_projects_raw = array();
$core_projects_raw = glob($core_project_path . "/*", GLOB_ONLYDIR);
// Extract the project name and add it to a single list.
foreach ($core_projects_raw as $core_project) {
$core_projects[] = basename($core_project);
$locations = array('core');
$core_projects_set = download_bee_find_all_projects($project_type, $locations);

// Add each project to a common array.
foreach ($core_projects_set as $key => $core_project) {
$core_projects[$key] = $core_project;
// Create a simple array of names for debug purposes.
$core_project_list[] = $key;
}
}
// Provide list of core projects for debug purposes.
bee_message(bt("Core projects are: !list", array(
'!list' => implode(",", $core_projects),
'!list' => implode(",", $core_project_list),
)), 'log');
}

Expand Down Expand Up @@ -154,7 +156,7 @@ function download_bee_callback($arguments, $options) {
$dependency = explode(" ", $dependency, 2);
$dependency = $dependency[0];
// Check if the dependency is a core project.
$dependency_is_core = in_array($dependency, $core_projects);
$dependency_is_core = isset($core_projects[$dependency]);
// Check if dependency exists in the site file system. Only
// check contrib dependencies.
if (!$dependency_is_core) {
Expand Down Expand Up @@ -535,21 +537,26 @@ function download_bee_download_project($project, array $info, $destination) {
* The type of project to list:
* - module
* - theme
* - layout
* This will find projects in both core and contrib.
* - layout.
* @param array $locations
* Array of 'locations'. These are not path locations, but location types. By
* default, this is 'core' and 'contrib', but you could limit to just 'core'
* or just 'contrib'.
*
* @return array
* An associative array of all projects with their locations, together with
* the location type and project type.
*/
function download_bee_find_all_projects($type) {
function download_bee_find_all_projects($type,
array $locations = array('core', 'contrib')) {
global $_bee_backdrop_root, $_bee_backdrop_site;
// Create an empty array for files.
$files = array();
// Create an empty array for projects.
$projects = array();
// Set the pattern to look for .info files.
$pattern = '#\.info$#';
// Define the locations to search.
$locations = array('core','contrib');
// Check if we need to add 'site_contrib' to list of locations.
(empty($_bee_backdrop_site)) ?: $locations[] = 'site_contrib';
// Loop through each location.
foreach ($locations as $location) {
Expand All @@ -574,7 +581,6 @@ function download_bee_find_all_projects($type) {
);
$files = bee_file_scan_directory($path, $pattern, $options);
// Modify each record to meet our needs.
$projects[] = array();
foreach ($files as &$file) {
// Add the revised project record to a common list of projects.
$key = $file->name;
Expand Down

0 comments on commit a26e570

Please sign in to comment.