Skip to content

Commit 2c62bb0

Browse files
authoredNov 26, 2024··
Merge pull request #74 from acquia/ACMS-4333
ACMS-4333: Fixed the bug reported in D11.
2 parents 691c63f + ba0c74b commit 2c62bb0

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed
 

‎src/Config/DefaultDrushConfig.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(?DrushConfig $config = NULL) {
2626
}
2727
$this->set('drush.bin', $config->get("runtime.drush-script"));
2828
$this->setDefault('drush.alias', "self");
29+
$this->setDefault('drush.uri', $config->get('options.uri'));
2930
$this->combine($config->export());
3031
}
3132
}

‎src/Drush/Commands/BaseDrushCommands.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function switchSiteContext(string $site_name): void {
113113
*/
114114
protected function initializeConfig(string $site_name = ""): void {
115115
$config = new DefaultDrushConfig($this->getConfig());
116-
$configInitializer = new ConfigInitializer($config, $this->input());
116+
$configInitializer = new ConfigInitializer($config);
117117
if ($site_name) {
118118
$configInitializer->setSite($site_name);
119119
}

‎src/Robo/Config/ConfigAwareTrait.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
namespace Acquia\Drupal\RecommendedSettings\Robo\Config;
44

5+
use Acquia\Drupal\RecommendedSettings\Config\ConfigInitializer;
6+
use Acquia\Drupal\RecommendedSettings\Config\DefaultDrushConfig;
57
use Drush\Config\ConfigAwareTrait as DrushConfigAwareTrait;
8+
use Drush\Config\DrushConfig;
69

710
/**
811
* Adds custom methods to DrushConfigAwareTrait.
912
*/
1013
trait ConfigAwareTrait {
1114

12-
use DrushConfigAwareTrait;
15+
use DrushConfigAwareTrait {
16+
DrushConfigAwareTrait::getConfig as parentDrushGetConfig;
17+
}
18+
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function getConfig(): DrushConfig {
23+
if (!$this->config instanceof DefaultDrushConfig) {
24+
$this->config = new DefaultDrushConfig($this->parentDrushGetConfig());
25+
}
26+
return $this->config;
27+
}
1328

1429
/**
1530
* {@inheritdoc}

‎src/Robo/Tasks/DrushTask.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Acquia\Drupal\RecommendedSettings\Robo\Tasks;
44

5+
use Acquia\Drupal\RecommendedSettings\Robo\Config\ConfigAwareTrait;
56
use Robo\Common\CommandArguments;
67
use Robo\Exception\TaskException;
78
use Robo\Task\CommandStack;
@@ -22,6 +23,7 @@
2223
*/
2324
class DrushTask extends CommandStack {
2425

26+
use ConfigAwareTrait;
2527
use CommandArguments {
2628
option as traitOption;
2729
}

‎tests/src/Functional/Config/DefaultDrushConfigTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ public function testDefaultDrushConfigData(): void {
2525
$drushConfig->set("options.root", $drupal_root);
2626
$drushConfig->set("drush.vendor-dir", $project_root . "/vendor");
2727
$drushConfig->set("options.ansi", TRUE);
28+
$drushConfig->set('drush.uri', '/var/www/html/acms.prod/vendor/bin');
2829
$drushConfig->set("runtime.drush-script", $project_root . "/vendor/bin/drush");
2930

3031
$default_drush_config = new DefaultDrushConfig($drushConfig);
3132
$actual = $default_drush_config->export();
3233
$this->assertEquals($actual, [
3334
"drush" => [
3435
"alias" => "self",
35-
"vendor-dir" => $project_root . "/vendor",
36+
"uri" => '/var/www/html/acms.prod/vendor/bin',
3637
"ansi" => TRUE,
3738
"bin" => $project_root . "/vendor/bin/drush",
39+
"vendor-dir" => $project_root . "/vendor",
3840
],
3941
"runtime" => [
4042
"project" => $project_root,

‎tests/src/unit/Robo/Config/ConfigAwareTraitTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ class ConfigAwareTraitTest extends TestCase {
2121
*/
2222
public function testGetConfigValue(): void {
2323
$this->config = new DrushConfig();
24-
// Tests when no value exist for the key, then default value must return.
24+
// Tests that default value for key is always set to /bin.
2525
$this->assertEquals(
26-
"/var/www/html/acms.prod/vendor/bin",
27-
$this->getConfigValue("composer.bin", "/var/www/html/acms.prod/vendor/bin"),
26+
"/bin",
27+
$this->getConfigValue("composer.bin"),
2828
);
2929
$drush_config = new DrushConfig();
30+
$drush_config->set('drush.uri', '/var/www/html/acms.prod/vendor/bin');
3031
$drush_config->set("runtime.project", "/var/www/html/acms.prod");
3132
$drush_config->set("options.root", "/var/www/html/acms.prod/docroot");
3233
$drush_config->set("drush.vendor-dir", $drush_config->get("runtime.project") . "/vendor");

0 commit comments

Comments
 (0)