Skip to content

Commit b302120

Browse files
Do not pass local paths to remote hosts (#3658)
* Do not pass local paths to remote hosts
1 parent 1b7a9b3 commit b302120

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

includes/backend.inc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,15 @@ function drush_backend_invoke_concurrent($invocations, $common_options = [], $co
745745
// Add in command-specific options as well
746746
// $command_options += drush_command_get_command_specific_options($site_record, $command);
747747

748+
$is_remote = array_key_exists('remote-host', $site_record);
749+
748750
// Add in preflight option contexts (--include et. al)
749-
$preflightContextOptions =
750-
\Drush\Drush::config()->get(PreflightArgs::DRUSH_RUNTIME_CONTEXT_NAMESPACE, []) +
751-
\Drush\Drush::config()->get(PreflightArgs::DRUSH_CONFIG_PATH_NAMESPACE, []);
751+
$preflightContextOptions = \Drush\Drush::config()->get(PreflightArgs::DRUSH_RUNTIME_CONTEXT_NAMESPACE, []);
752752
$preflightContextOptions['local'] = \Drush\Drush::config()->get('runtime.local', false);
753+
// If the command is local, also include the paths context.
754+
if (!$is_remote) {
755+
$preflightContextOptions += \Drush\Drush::config()->get(PreflightArgs::DRUSH_CONFIG_PATH_NAMESPACE, []);
756+
}
753757
foreach ($preflightContextOptions as $key => $value) {
754758
if ($value) {
755759
$command_options[$key] = $value;

tests/BackendTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testDispatchUsingAlias()
4141
$output = preg_replace('# *#', ' ', $output);
4242
$output = preg_replace('# -t #', ' ', $output); // volkswagon away the -t, it's not relevant to what we're testing here
4343
$output = preg_replace('#' . self::getSandbox() . '#', '__SANDBOX__', $output);
44-
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=no [email protected] '/usr/local/bin/drush --alias-path=__SANDBOX__/etc/drush/sites --root=/path/to/drupal --uri=http://example.com --no-interaction status", $output);
44+
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=no [email protected] '/usr/local/bin/drush --root=/path/to/drupal --uri=http://example.com --no-interaction status", $output);
4545
}
4646

4747
/**

tests/SqlSyncTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testSimulatedSqlSync()
4545
// Test simulated simple rsync remote-to-local
4646
$this->drush('sql:sync', ['@synctest.remote', '@synctest.local'], $options, '@synctest.local', null, self::EXIT_SUCCESS, '2>&1');
4747
$output = $this->getSimplifiedOutput();
48-
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=whatever [email protected] '/path/to/drush --backend=2 --strict=0 $expectedAliasPath --root=__SUT__/web --uri=remote sql-dump --no-interaction --gzip --result-file", $output);
48+
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=whatever [email protected] '/path/to/drush --backend=2 --strict=0 --root=__SUT__/web --uri=remote sql-dump --no-interaction --gzip --result-file", $output);
4949
$this->assertContains("Simulating backend invoke: __SUT__/vendor/drush/drush/drush --backend=2 $expectedAliasPath --root=__SUT__/web --uri=local core-rsync '@synctest.remote:/simulated/path/to/dump.tgz' '@synctest.local:__SANDBOX__/tmp/dump.tgz' -- --remove-source-files", $output);
5050
$this->assertContains("Simulating backend invoke: __SUT__/vendor/drush/drush/drush --backend=2 --strict=0 $expectedAliasPath --root=__SUT__/web --uri=local sql-query --no-interaction --file=__SANDBOX__/tmp/dump.tgz --file-delete", $output);
5151

@@ -54,7 +54,7 @@ public function testSimulatedSqlSync()
5454
$output = $this->getSimplifiedOutput();
5555
$this->assertContains("Simulating backend invoke: __SUT__/vendor/drush/drush/drush --backend=2 --strict=0 $expectedAliasPath --root=__SUT__/web --uri=local sql-dump --no-interaction --gzip --result-file", $output);
5656
$this->assertContains("Simulating backend invoke: __SUT__/vendor/drush/drush/drush --backend=2 $expectedAliasPath --root=__SUT__/web --uri=local core-rsync '@synctest.local:/simulated/path/to/dump.tgz' '@synctest.remote:/tmp/dump.tgz' -- --remove-source-files", $output);
57-
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=whatever [email protected] '/path/to/drush --backend=2 --strict=0 $expectedAliasPath --root=__SUT__/web --uri=remote sql-query --no-interaction --file=/tmp/dump.tgz --file-delete", $output);
57+
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=whatever [email protected] '/path/to/drush --backend=2 --strict=0 --root=__SUT__/web --uri=remote sql-query --no-interaction --file=/tmp/dump.tgz --file-delete", $output);
5858

5959

6060
// Test simulated backend invoke with a remote runner.
@@ -63,7 +63,7 @@ public function testSimulatedSqlSync()
6363
// they are used with drush_invoke_process.
6464
$this->drush('sql:sync', ['@synctest.remote', '@synctest.local'], $options, 'user@server/path/to/drupal#sitename', null, self::EXIT_SUCCESS, '2>&1');
6565
$output = $this->getSimplifiedOutput();
66-
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=no user@server 'drush $expectedAliasPath --root=/path/to/drupal --uri=sitename --no-interaction sql:sync '\''@synctest.remote'\'' '\''@synctest.local'\''", $output);
66+
$this->assertContains("Simulating backend invoke: ssh -o PasswordAuthentication=no user@server 'drush --root=/path/to/drupal --uri=sitename --no-interaction sql:sync '\''@synctest.remote'\'' '\''@synctest.local'\''", $output);
6767
}
6868

6969
/**

0 commit comments

Comments
 (0)