From b57f60b4eea153901308177ff17097ba9a1df3e4 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 19 May 2009 22:50:12 +0000 Subject: [PATCH] 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 --- core/control/Director.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/control/Director.php b/core/control/Director.php index 919aa6ec7..cdfc4eff3 100644 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -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 * 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. * * 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)) { 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; } @@ -789,6 +787,15 @@ class Director { * For information about environment types, see {@link Director::set_environment_type()}. */ 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::$environment_type) {