From 0a78313c044e9ce1b038d9925699a58f3fe3e097 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 6 Mar 2022 07:09:56 -0500 Subject: [PATCH] Canonicalize all paths in status output. (#5049) * Canonicalize all paths in status output. * Filter null paths --- src/Commands/core/StatusCommands.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Commands/core/StatusCommands.php b/src/Commands/core/StatusCommands.php index 843e721bba..a4191c5db5 100644 --- a/src/Commands/core/StatusCommands.php +++ b/src/Commands/core/StatusCommands.php @@ -15,6 +15,7 @@ use Consolidation\SiteAlias\SiteAliasManagerAwareTrait; use Consolidation\OutputFormatters\Options\FormatterOptions; use Consolidation\AnnotatedCommand\CommandData; +use Webmozart\PathUtil\Path; class StatusCommands extends DrushCommands implements SiteAliasManagerAwareInterface { @@ -92,7 +93,7 @@ public function getPropertyList($options): array if (($drupal_root = $boot_manager->getRoot()) && ($boot_object instanceof DrupalBoot)) { $status_table['drupal-version'] = $boot_object->getVersion($drupal_root); $conf_dir = $boot_object->confPath(); - $settings_file = "$conf_dir/settings.php"; + $settings_file = Path::join($conf_dir, 'settings.php'); $status_table['drupal-settings-file'] = file_exists($settings_file) ? $settings_file : ''; if ($boot_manager->hasBootstrapped(DRUSH_BOOTSTRAP_DRUPAL_SITE)) { $status_table['uri'] = $boot_manager->getUri(); @@ -130,21 +131,21 @@ public function getPropertyList($options): array $status_table['admin-theme'] = $theme = \Drupal::config('system.theme')->get('admin') ?: 'seven'; } } - $status_table['php-bin'] = PHP_BINARY; + $status_table['php-bin'] = Path::canonicalize(PHP_BINARY); $status_table['php-os'] = PHP_OS; if ($phpIniFiles = EditCommands::phpIniFiles()) { - $status_table['php-conf'] = $phpIniFiles; + $status_table['php-conf'] = array_map('Webmozart\PathUtil\Path::canonicalize', $phpIniFiles); } - $status_table['drush-script'] = $this->getConfig()->get('runtime.drush-script'); + $status_table['drush-script'] = Path::canonicalize($this->getConfig()->get('runtime.drush-script')); $status_table['drush-version'] = Drush::getVersion(); - $status_table['drush-temp'] = $this->getConfig()->tmp(); - $status_table['drush-conf'] = $this->getConfig()->configPaths(); + $status_table['drush-temp'] = Path::canonicalize($this->getConfig()->tmp()); + $status_table['drush-conf'] = array_map('Webmozart\PathUtil\Path::canonicalize', $this->getConfig()->configPaths()); // List available alias files $alias_files = $this->siteAliasManager()->listAllFilePaths(); sort($alias_files); $status_table['drush-alias-files'] = $alias_files; $alias_searchpaths = $this->siteAliasManager()->searchLocations(); - $status_table['alias-searchpaths'] = $alias_searchpaths; + $status_table['alias-searchpaths'] = array_map('Webmozart\PathUtil\Path::canonicalize', $alias_searchpaths); $paths = self::pathAliases($options, $boot_manager, $boot_object); if (!empty($paths)) { @@ -160,7 +161,7 @@ public function getPropertyList($options): array // Store the paths into the '%paths' index; this will be // used by other code, but will not be included in the default output // of the drush status command. - $status_table['%paths'] = $paths; + $status_table['%paths'] = array_map('Webmozart\PathUtil\Path::canonicalize', array_filter($paths)); return $status_table; }