mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR #3951 Allow setting test mode by calling ?isTest=1 from the URL (ronan)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@77269 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a1d17bc6e0
commit
b57f60b4ee
@ -692,6 +692,10 @@ class Director {
|
|||||||
*
|
*
|
||||||
* Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev
|
* Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev
|
||||||
* mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back.
|
* mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back.
|
||||||
|
*
|
||||||
|
* Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the site into test
|
||||||
|
* mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back.
|
||||||
|
*
|
||||||
* Generally speaking, these methods will be called from your _config.php file.
|
* Generally speaking, these methods will be called from your _config.php file.
|
||||||
*
|
*
|
||||||
* Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and
|
* Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and
|
||||||
@ -774,12 +778,6 @@ class Director {
|
|||||||
if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
|
if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// Check if we are running on one of the test servers
|
|
||||||
if(in_array($_SERVER['HTTP_HOST'], Director::$test_servers)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -789,6 +787,15 @@ class Director {
|
|||||||
* For information about environment types, see {@link Director::set_environment_type()}.
|
* For information about environment types, see {@link Director::set_environment_type()}.
|
||||||
*/
|
*/
|
||||||
static function isTest() {
|
static function isTest() {
|
||||||
|
// Use ?isTest=1 to get test access on the live server, or explicitly set your environment
|
||||||
|
if(isset($_GET['isTest'])) {
|
||||||
|
if(Security::database_is_ready()) {
|
||||||
|
BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN");
|
||||||
|
$_SESSION['isTest'] = $_GET['isTest'];
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(self::isDev()) return false;
|
if(self::isDev()) return false;
|
||||||
|
|
||||||
if(self::$environment_type) {
|
if(self::$environment_type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user