Skip to content

Commit

Permalink
Merge pull request #26 from mateu-aguilo-bosch/23-drupal-root-detection
Browse files Browse the repository at this point in the history
Use same Drupal root detection than drush.
  • Loading branch information
e0ipso committed Jul 1, 2015
2 parents c90ecd8 + c74f7e5 commit 4368d2b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/Discovery/PathFinderCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function find($seed) {
* TRUE if the passed directory is the Drupal root.
*/
protected function isDrupalRoot($directory) {
// Check if there is a COPYRIGHT.txt file in the directory.
$copyrightPath = $directory . DIRECTORY_SEPARATOR . 'COPYRIGHT.txt';
if (!$check = file_exists($copyrightPath)) {
return FALSE;
if (!empty($directory) && is_dir($directory) && file_exists($directory . DIRECTORY_SEPARATOR . '/index.php')) {
// Drupal 7 root.
// We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
return (file_exists($directory . DIRECTORY_SEPARATOR . 'includes/common.inc')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'misc/drupal.js')
&& file_exists($directory . DIRECTORY_SEPARATOR . 'modules/field/field.module'));
}
// Make sure that the COPYRIGHT.txt file corresponds to Drupal.
$line = fgets(fopen($copyrightPath, 'r'));
return strpos($line, 'All Drupal code is Copyright') === 0;
return FALSE;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/data/docroot/COPYRIGHT.txt

This file was deleted.

Empty file.
Empty file added tests/data/docroot/index.php
Empty file.
Empty file.
Empty file.

0 comments on commit 4368d2b

Please sign in to comment.