From 194a99ce81bf5f3885da16a6f8822dd36b29eedb Mon Sep 17 00:00:00 2001
From: Pieter Frenssen <pieter@frenssen.be>
Date: Sat, 9 Jun 2012 00:16:05 +0200
Subject: [PATCH] Issue #1590274 by pfrenssen: Drupal root folder not detected properly.

---
 includes/environment.inc |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/includes/environment.inc b/includes/environment.inc
index 46af167..f586873 100644
--- a/includes/environment.inc
+++ b/includes/environment.inc
@@ -384,7 +384,10 @@ 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)) {
+      // If we are on D8 or higher and the current path is the 'core' folder we
+      // will get a false positive. Do an additional check to see if the Symfony
+      // HttpKernel library is present, since this has been introduced in D8.
+      if (file_exists($path . '/' . $candidate) && !file_exists($path . '/vendor/Symfony/Component/HttpKernel/HttpKernel.php')) {
         return $candidate;
       }
     }
-- 
1.7.4.1

