From 850ab0879f32d0624bc793964b93af57169911ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 10:44:37 +0000 Subject: [PATCH 1/6] Rely on project-level installed Drush version --- src/Drupal/Driver/DrushDriver.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Drupal/Driver/DrushDriver.php b/src/Drupal/Driver/DrushDriver.php index 8bcd116..7a61c66 100644 --- a/src/Drupal/Driver/DrushDriver.php +++ b/src/Drupal/Driver/DrushDriver.php @@ -71,14 +71,15 @@ class DrushDriver extends BaseDriver { * The root path of the Drupal install. This is an alternative to using * aliases. * @param string $binary - * The path to the drush binary. + * The path to the drush binary. Defaults to the Drush instance installed + * on the project-level. * @param \Drupal\Component\Utility\Random $random * Random generator. * * @throws \Drupal\Driver\Exception\BootstrapException * Thrown when a required parameter is missing. */ - public function __construct($alias = NULL, $root_path = NULL, $binary = 'drush', Random $random = NULL) { + public function __construct($alias = NULL, $root_path = NULL, $binary = '', Random $random = NULL) { if (!empty($alias)) { // Trim off the '@' symbol if it has been added. $alias = ltrim($alias, '@'); @@ -92,6 +93,11 @@ public function __construct($alias = NULL, $root_path = NULL, $binary = 'drush', throw new BootstrapException('A drush alias or root path is required.'); } + if ($binary === '') { + global $_composer_bin_dir; + $binary = $_composer_bin_dir . '/drush'; + } + $this->binary = $binary; if (!isset($random)) { From e214922815fc87bd2eb6dd0aed057aec45df6ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 10:51:49 +0000 Subject: [PATCH 2/6] Require "composer-runtime-api": "^2.2.2" https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-bin-dir-from-a-binary --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 49599f5..755bd08 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ ], "require": { "php": ">=7.4", + "composer-runtime-api": "^2.2.2", "symfony/process": "~2.5|~3.0|~4.4|^6", "symfony/dependency-injection": "~2.6|~3.0|~4.4|^6", "drupal/core-utility": "^8.4 || ^9 || ^10@beta" From 30326ce8f457c7df89f5617a143e8f5c9251c35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 11:33:06 +0000 Subject: [PATCH 3/6] Add deprecation errors --- src/Drupal/Driver/DrushDriver.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Drupal/Driver/DrushDriver.php b/src/Drupal/Driver/DrushDriver.php index 7a61c66..6f58658 100644 --- a/src/Drupal/Driver/DrushDriver.php +++ b/src/Drupal/Driver/DrushDriver.php @@ -95,9 +95,18 @@ public function __construct($alias = NULL, $root_path = NULL, $binary = '', Rand if ($binary === '') { global $_composer_bin_dir; - $binary = $_composer_bin_dir . '/drush'; + + $binary = $_composer_bin_dir . '/drusha'; + if (!file_exists($binary)) { + trigger_error("Using the Drush Driver without Drush installed at the project level is deprecated in Drupal Driver 2.2.3 and will be removed in 3.0.0. Please ensure Drush is installed on the project level by running 'composer require drush/drush'.", E_USER_DEPRECATED); + $binary = 'drush'; + } } + if ($binary === 'drush') { + trigger_error("Relying on the globally installed Drush binary via Drush Launcher is deprecated in Drupal Driver 2.2.3 and will be removed in 3.0.0. Please ensure Drush is installed on the project level by running 'composer require drush/drush'.", E_USER_DEPRECATED); + } + $this->binary = $binary; if (!isset($random)) { From 55271fe013fe30e59e5cb872070c704bfb95293d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 11:38:03 +0000 Subject: [PATCH 4/6] Add Drush as dev dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 755bd08..23043ba 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "require-dev": { "composer/installers": "^2.1", "drupal/coder": "~8.3.0", + "drush/drush": "^12", "phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main", "phpunit/phpunit": "~6.0 || ~7.0 || ^9", "mockery/mockery": "^1.5", From 20b8dce000e4bb07c83655be1bcf49d5a40426fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 11:40:49 +0000 Subject: [PATCH 5/6] Add Drush 11, as long as only PHP < 8.1 builds passes on GHA --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 23043ba..3d7acb7 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "require-dev": { "composer/installers": "^2.1", "drupal/coder": "~8.3.0", - "drush/drush": "^12", + "drush/drush": "^11 || ^12", "phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main", "phpunit/phpunit": "~6.0 || ~7.0 || ^9", "mockery/mockery": "^1.5", From e027dd2f026e7d5014362d5988bd8d719be631eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Mon, 11 Mar 2024 11:43:50 +0000 Subject: [PATCH 6/6] Typo fix --- src/Drupal/Driver/DrushDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drupal/Driver/DrushDriver.php b/src/Drupal/Driver/DrushDriver.php index 6f58658..dac414c 100644 --- a/src/Drupal/Driver/DrushDriver.php +++ b/src/Drupal/Driver/DrushDriver.php @@ -96,7 +96,7 @@ public function __construct($alias = NULL, $root_path = NULL, $binary = '', Rand if ($binary === '') { global $_composer_bin_dir; - $binary = $_composer_bin_dir . '/drusha'; + $binary = $_composer_bin_dir . '/drush'; if (!file_exists($binary)) { trigger_error("Using the Drush Driver without Drush installed at the project level is deprecated in Drupal Driver 2.2.3 and will be removed in 3.0.0. Please ensure Drush is installed on the project level by running 'composer require drush/drush'.", E_USER_DEPRECATED); $binary = 'drush';