summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhansfn2013-01-11 10:41:19 (GMT)
committer Jonathan AraƱa Cruz2013-01-11 10:41:19 (GMT)
commit8d93640c244d66cd357aa9a982774fb5272f292e (patch)
tree4c1985a3db2c8e831cbb22467f4556c5d999080b
parentccf82b6dd3d7b6690d1428d85018d450537b955f (diff)
Issue #1874726 by hansfn, jonhattan: Fixed Wrong Drupal root if running Drush inside the D8 'core' directory .
-rw-r--r--includes/environment.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/includes/environment.inc b/includes/environment.inc
index b0cb3cd..cc8b385 100644
--- a/includes/environment.inc
+++ b/includes/environment.inc
@@ -382,11 +382,16 @@ function drush_locate_root($start_path = NULL) {
*/
function drush_valid_drupal_root($path) {
if (!empty($path) && is_dir($path)) {
- $candidates = array('includes/common.inc', 'core/includes/common.inc');
- foreach ($candidates as $candidate) {
- if (file_exists($path . '/' . $candidate)) {
- return $candidate;
- }
+ // Drupal 8 root.
+ $candidate = 'core/includes/common.inc';
+ if (file_exists($path . '/' . $candidate)) {
+ return $candidate;
+ }
+ // Drupal 7 root. Ensure $path is not inside core/ of a Drupal 8 root.
+ // Double check: parent is core/ and ../sites/example.sites.php exists.
+ $candidate = 'includes/common.inc';
+ if (file_exists($path . '/' . $candidate) && ((basename($path) != 'core') && !file_exists($path . '../sites/example.sites.php'))) {
+ return $candidate;
}
}
return FALSE;