mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3867 from Zauberfisch/patch-5
Fixed looking for _ss_environment.php in root dir
This commit is contained in:
commit
1879b2ecf6
@ -49,7 +49,7 @@ if ($dirsToCheck[0] == $dirsToCheck[1]) {
|
||||
foreach ($dirsToCheck as $dir) {
|
||||
//check this dir and every parent dir (until we hit the base of the drive)
|
||||
// or until we hit a dir we can't read
|
||||
do {
|
||||
while(true) {
|
||||
//add the trailing slash we need to concatenate properly
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
//if it's readable, go ahead
|
||||
@ -66,11 +66,14 @@ foreach ($dirsToCheck as $dir) {
|
||||
//break out of the while loop, we can't read the dir
|
||||
break;
|
||||
}
|
||||
if (dirname($dir) == $dir) {
|
||||
// here we need to check that the path of the last dir and the next one are
|
||||
// not the same, if they are, we have hit the root of the drive
|
||||
break;
|
||||
}
|
||||
//go up a directory
|
||||
$dir = dirname($dir);
|
||||
//here we need to check that the path of the last dir and the next one are
|
||||
// not the same, if they are, we have hit the root of the drive
|
||||
} while (dirname($dir) != $dir);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,60 +31,12 @@ if(function_exists('session_start') && !session_id()) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Include _ss_environment.php file
|
||||
*/
|
||||
$usingEnv = false;
|
||||
$envFileExists = false;
|
||||
//define the name of the environment file
|
||||
$envFile = '_ss_environment.php';
|
||||
//define the dirs to start scanning from (have to add the trailing slash)
|
||||
// we're going to check the realpath AND the path as the script sees it
|
||||
$dirsToCheck = array(
|
||||
realpath('.'),
|
||||
dirname($_SERVER['SCRIPT_FILENAME'])
|
||||
);
|
||||
//if they are the same, remove one of them
|
||||
if($dirsToCheck[0] == $dirsToCheck[1]) {
|
||||
unset($dirsToCheck[1]);
|
||||
}
|
||||
foreach($dirsToCheck as $dir) {
|
||||
//check this dir and every parent dir (until we hit the base of the drive)
|
||||
// or until we hit a dir we can't read
|
||||
do {
|
||||
//add the trailing slash we need to concatenate properly
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
//if it's readable, go ahead
|
||||
if(@is_readable($dir)) {
|
||||
//if the file exists, then we include it, set relevant vars and break out
|
||||
if(file_exists($dir . $envFile)) {
|
||||
include_once($dir . $envFile);
|
||||
$envFileExists = true;
|
||||
//legacy variable assignment
|
||||
$usingEnv = true;
|
||||
//break out of BOTH loops because we found the $envFile
|
||||
break(2);
|
||||
}
|
||||
} else {
|
||||
//break out of the while loop, we can't read the dir
|
||||
break;
|
||||
}
|
||||
//go up a directory
|
||||
$dir = dirname($dir);
|
||||
//here we need to check that the path of the last dir and the next one are
|
||||
// not the same, if they are, we have hit the root of the drive
|
||||
} while(dirname($dir) != $dir);
|
||||
}
|
||||
|
||||
if($envFileExists) {
|
||||
if(!empty($_REQUEST['useEnv'])) {
|
||||
$usingEnv = true;
|
||||
} else {
|
||||
$usingEnv = false;
|
||||
}
|
||||
}
|
||||
|
||||
require_once FRAMEWORK_NAME . '/core/Constants.php'; // this also includes TempPath.php
|
||||
|
||||
$usingEnv = false;
|
||||
$envFileExists = defined('SS_ENVIRONMENT_FILE');
|
||||
$usingEnv = $envFileExists && !empty($_REQUEST['useEnv']);
|
||||
|
||||
require_once FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php';
|
||||
require_once FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user