mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #218 from mrmorphic/6856-isdev-bug-rc
bugfix for 6856, isDev=1&showqueries going into infinite loop
This commit is contained in:
commit
e307594c05
@ -802,19 +802,31 @@ class Director implements TemplateGlobalProvider {
|
|||||||
/**
|
/**
|
||||||
* This function will return true if the site is in a development environment.
|
* This function will return true if the site is in a development environment.
|
||||||
* For information about environment types, see {@link Director::set_environment_type()}.
|
* For information about environment types, see {@link Director::set_environment_type()}.
|
||||||
|
* @param $dontTouchDB If true, the database checks are not performed, which allows certain DB checks
|
||||||
|
* to not fail before the DB is ready. If false (default), DB checks are included.
|
||||||
*/
|
*/
|
||||||
static function isDev() {
|
static function isDev($dontTouchDB = false) {
|
||||||
// This variable is used to supress repetitions of the isDev security message below.
|
// This variable is used to supress repetitions of the isDev security message below.
|
||||||
static $firstTimeCheckingGetVar = true;
|
static $firstTimeCheckingGetVar = true;
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
if(isset($_SESSION['isDev']) && $_SESSION['isDev']) $result = true;
|
||||||
|
if(self::$environment_type && self::$environment_type == 'dev') $result = true;
|
||||||
|
|
||||||
|
if(!empty(Director::$dev_servers)) {
|
||||||
|
Deprecation::notice('3.0', 'Director::$dev_servers doesn\'t work anymore');
|
||||||
|
}
|
||||||
|
|
||||||
// Use ?isDev=1 to get development access on the live server
|
// Use ?isDev=1 to get development access on the live server
|
||||||
if(isset($_GET['isDev'])) {
|
if(!$dontTouchDB && !$result && isset($_GET['isDev'])) {
|
||||||
if(Security::database_is_ready()) {
|
if(Security::database_is_ready()) {
|
||||||
if($firstTimeCheckingGetVar && !Permission::check('ADMIN')){
|
if($firstTimeCheckingGetVar && !Permission::check('ADMIN')){
|
||||||
BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN");
|
BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN");
|
||||||
}
|
}
|
||||||
$_SESSION['isDev'] = $_GET['isDev'];
|
$_SESSION['isDev'] = $_GET['isDev'];
|
||||||
if($firstTimeCheckingGetVar) $firstTimeCheckingGetVar = false;
|
$firstTimeCheckingGetVar = false;
|
||||||
|
$result = $_GET['isDev'];
|
||||||
} else {
|
} else {
|
||||||
if($firstTimeCheckingGetVar && DB::connection_attempted()) {
|
if($firstTimeCheckingGetVar && DB::connection_attempted()) {
|
||||||
echo "<p style=\"padding: 3px; margin: 3px; background-color: orange;
|
echo "<p style=\"padding: 3px; margin: 3px; background-color: orange;
|
||||||
@ -826,16 +838,7 @@ class Director implements TemplateGlobalProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_SESSION['isDev']) && $_SESSION['isDev']) return true;
|
return $result;
|
||||||
|
|
||||||
if(self::$environment_type) return self::$environment_type == 'dev';
|
|
||||||
|
|
||||||
// Check if we are running on one of the development servers
|
|
||||||
if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,13 +109,13 @@ class MySQLDatabase extends SS_Database {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_REQUEST['showqueries'])) {
|
if(isset($_REQUEST['showqueries']) && Director::isDev(true)) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$handle = $this->dbConn->query($sql);
|
$handle = $this->dbConn->query($sql);
|
||||||
|
|
||||||
if(isset($_REQUEST['showqueries'])) {
|
if(isset($_REQUEST['showqueries']) && Director::isDev(true)) {
|
||||||
$endtime = round(microtime(true) - $starttime,4);
|
$endtime = round(microtime(true) - $starttime,4);
|
||||||
Debug::message("\n$sql\n{$endtime}ms\n", false);
|
Debug::message("\n$sql\n{$endtime}ms\n", false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user