Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rely on project-level installed Drush version #273

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
],
"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"
},
"require-dev": {
"composer/installers": "^2.1",
"drupal/coder": "~8.3.0",
"drush/drush": "^11 || ^12",
Copy link
Author

@mxr576 mxr576 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only Drush >=12 is supported, Drush 11 should not be on the list, but only PHP <8.1 builds are passing atm.

https://www.drush.org/12.4.4/install/#drupal-compatibility

"phpspec/phpspec": "~2.0 || ~4.0 || ~6.1 || dev-main",
"phpunit/phpunit": "~6.0 || ~7.0 || ^9",
"mockery/mockery": "^1.5",
Expand Down
19 changes: 17 additions & 2 deletions src/Drupal/Driver/DrushDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '@');
Expand All @@ -92,6 +93,20 @@ 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';
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)) {
Expand Down
Loading