Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d1d2fc

Browse files
committed
Use Symfony process instead of custom exec functions
A modernized version of #673.
1 parent f8b92fa commit 5d1d2fc

24 files changed

+228
-68
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# UNISH_NO_TIMEOUTS=y
1111
# Uncomment to run tests against a different DB. Defaults to mysql.
1212
# UNISH_DB_URL=pgsql://unish:unish@postgres
13-
# UNISH_DB_URL=sqlite://sut/sites/default/files/.ht.sqlite
13+
# UNISH_DB_URL=sqlite://sut/sites/dev/files/.ht.sqlite
1414
#
1515
# XDebug defaults to Off in the php container.
1616
# Uncomment to enable XDebug. See https://wodby.com/stacks/drupal/docs/local/xdebug/.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"optimize-autoloader": true,
8585
"preferred-install": "dist",
8686
"sort-packages": true,
87-
"process-timeout": 2400,
87+
"process-timeout": 9600,
8888
"platform": {
8989
"php": "5.6"
9090
}

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ services:
1010
MYSQL_ROOT_PASSWORD: password
1111
volumes:
1212
- mariadb-datavolume:/var/lib/mysql
13+
ports:
14+
- '3006:3306'
1315

1416
# More info at https://github.com/wodby/php
1517
# We don't want their drupal-php image as that ships with a Drush inside.
@@ -41,6 +43,8 @@ services:
4143
POSTGRES_USER: unish
4244
volumes:
4345
- postgres-datavolume:/var/lib/postgresql/data
46+
ports:
47+
- '5532:5432'
4448

4549
#data volumes https://docs.docker.com/storage/volumes/
4650
volumes:

includes/exec.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use \Consolidation\SiteAlias\AliasRecord;
2727
* The result code from system(): 0 == success.
2828
*
2929
* @see drush_shell_exec()
30+
* @deprecated See Drush::process().
3031
*/
3132
function drush_op_system($exec) {
3233
if (Drush::verbose() || Drush::simulate()) {
@@ -52,6 +53,9 @@ function drush_op_system($exec) {
5253
* The command to execute. May include placeholders used for sprintf.
5354
* @param ...
5455
* Values for the placeholders specified in $cmd. Each of these will be passed through escapeshellarg() to ensure they are safe to use on the command line.
56+
*
57+
* @deprecated See Drush::process().
58+
*
5559
* @return
5660
* TRUE on success, FALSE on failure
5761
*/
@@ -76,6 +80,9 @@ function drush_shell_cd_and_exec($effective_wd, $cmd) {
7680
* The command to execute. May include placeholders used for sprintf.
7781
* @param ...
7882
* Values for the placeholders specified in $cmd. Each of these will be passed through escapeshellarg() to ensure they are safe to use on the command line.
83+
*
84+
* @deprecated See Drush::process().
85+
*
7986
* @return
8087
* TRUE on success, FALSE on failure
8188
*/
@@ -85,6 +92,8 @@ function drush_shell_exec($cmd) {
8592

8693
/**
8794
* A version of drush_shell_exec() that ignores simulate mode
95+
*
96+
* @deprecated See Drush::process().
8897
*/
8998
function drush_always_exec($cmd) {
9099
return _drush_shell_exec(func_get_args(), FALSE, FALSE);

scenarios/isolation-phpunit4/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"optimize-autoloader": true,
6363
"preferred-install": "dist",
6464
"sort-packages": true,
65-
"process-timeout": 2400,
65+
"process-timeout": 9600,
6666
"platform": {
6767

6868
},

scenarios/isolation/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"optimize-autoloader": true,
6363
"preferred-install": "dist",
6464
"sort-packages": true,
65-
"process-timeout": 2400,
65+
"process-timeout": 9600,
6666
"platform": {
6767

6868
},

src/Backend/BackendPathEvaluator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function request(AliasRecord $aliasRecord, $pathAlias)
7474
// The drupal:directory command uses a path evaluator, which
7575
// calls this function, so we cannot use dd here, as that
7676
// would be recursive.
77-
$values = drush_invoke_process($aliasRecord, "core-status", [], ['project' => $pathAlias], ['integrate' => false, 'override-simulated' => true]);
77+
$values = drush_invoke_process($aliasRecord, "core:status", [], ['project' => $pathAlias], ['integrate' => false, 'override-simulated' => true]);
7878
$statusValues = $values['object'];
7979
if (isset($statusValues[$pathAlias])) {
8080
return $statusValues[$pathAlias];

src/Commands/DrushCommands.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Drush\Commands;
33

4+
use Drush\Drush;
45
use Drush\Style\DrushStyle;
56
use Psr\Log\LoggerAwareInterface;
67
use Psr\Log\LoggerAwareTrait;
@@ -80,12 +81,17 @@ protected function printFile($file)
8081
}
8182

8283
if (self::input()->isInteractive()) {
83-
if (drush_shell_exec_interactive("less %s", $file)) {
84-
return;
85-
} elseif (drush_shell_exec_interactive("more %s", $file)) {
84+
;
85+
$process = Drush::process(['less', $file])->setTty(true);
86+
if ($process->run() === 0) {
8687
return;
8788
} else {
88-
$this->output()->writeln(file_get_contents($file));
89+
$process = Drush::process(['more', $file]);
90+
if ($process->run() === 0) {
91+
return;
92+
} else {
93+
$this->output()->writeln(file_get_contents($file));
94+
}
8995
}
9096
}
9197
}

src/Commands/core/RsyncCommands.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public function rsync($source, $target, array $extra, $options = ['exclude-paths
7373

7474
$ssh_options = Drush::config()->get('ssh.options', '');
7575
$exec = "rsync -e 'ssh $ssh_options'". ' '. implode(' ', array_filter($parameters));
76-
$exec_result = drush_op_system($exec);
76+
$exec_result = Drush::process($exec)->run();
7777

78-
if ($exec_result == 0) {
78+
if ($exec_result === 0) {
7979
drush_backend_set_result($this->targetEvaluatedPath->fullyQualifiedPath());
8080
} else {
8181
throw new \Exception(dt("Could not rsync from !source to !dest", ['!source' => $this->sourceEvaluatedPath->fullyQualifiedPathPreservingTrailingSlash(), '!dest' => $this->targetEvaluatedPath->fullyQualifiedPath()]));

src/Commands/core/SiteInstallCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public function pre(CommandData $commandData)
351351
$bootstrapManager->doBootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
352352

353353
if (!$sql->dropOrCreate()) {
354-
throw new \Exception(dt('Failed to create database: @error', ['@error' => implode(drush_shell_exec_output())]));
354+
throw new \Exception(dt('Failed to drop or create the database: @error', ['@error' => $sql->getProcess()->getOutput()]));
355355
}
356356
}
357357

0 commit comments

Comments
 (0)