mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Checking for class_exists() before SapphireTest::is_running_tests() to avoid including the whole testing framework, and triggering PHPUnit to run a performance-intensive directory traversal for coverage file blacklists (from r114332)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@114334 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5236e09026
commit
30e3f08efb
@ -649,7 +649,7 @@ class Director {
|
||||
$destURL = str_replace('http:', 'https:', Director::absoluteURL($_SERVER['REQUEST_URI']));
|
||||
|
||||
// This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests
|
||||
if(SapphireTest::is_running_test()) {
|
||||
if(class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
|
||||
return $destURL;
|
||||
} else {
|
||||
if(!headers_sent()) header("Location: $destURL");
|
||||
|
@ -29,12 +29,13 @@ class DatabaseAdmin extends Controller {
|
||||
// if on CLI or with the database not ready. The latter makes it less errorprone to do an
|
||||
// initial schema build without requiring a default-admin login.
|
||||
// Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
|
||||
$isRunningTests = (class_exists('SapphireTest', false) && SapphireTest::is_running_test());
|
||||
$canAccess = (
|
||||
Director::isDev()
|
||||
|| !Security::database_is_ready()
|
||||
// We need to ensure that DevelopmentAdminTest can simulate permission failures when running
|
||||
// "dev/tests" from CLI.
|
||||
|| (Director::is_cli() && !SapphireTest::is_running_test())
|
||||
|| (Director::is_cli() && !$isRunningTests)
|
||||
|| Permission::check("ADMIN")
|
||||
);
|
||||
if(!$canAccess) {
|
||||
|
@ -12,12 +12,13 @@ class TaskRunner extends Controller {
|
||||
|
||||
function init() {
|
||||
parent::init();
|
||||
|
||||
|
||||
$isRunningTests = (class_exists('SapphireTest', false) && SapphireTest::is_running_test());
|
||||
$canAccess = (
|
||||
Director::isDev()
|
||||
// We need to ensure that DevelopmentAdminTest can simulate permission failures when running
|
||||
// "dev/tasks" from CLI.
|
||||
|| (Director::is_cli() && !SapphireTest::is_running_test())
|
||||
|| (Director::is_cli() && !$isRunningTests)
|
||||
|| Permission::check("ADMIN")
|
||||
);
|
||||
if(!$canAccess) return Security::permissionFailure($this);
|
||||
|
@ -476,7 +476,8 @@ class Upload_Validator {
|
||||
// we don't validate for empty upload fields yet
|
||||
if(!isset($this->tmpFile['name']) || empty($this->tmpFile['name'])) return true;
|
||||
|
||||
if(isset($this->tmpFile['tmp_name']) && !is_uploaded_file($this->tmpFile['tmp_name']) && !SapphireTest::is_running_test()) {
|
||||
$isRunningTests = (class_exists('SapphireTest', false) && SapphireTest::is_running_test());
|
||||
if(isset($this->tmpFile['tmp_name']) && !is_uploaded_file($this->tmpFile['tmp_name']) && !$isRunningTests) {
|
||||
$this->errors[] = _t('File.NOVALIDUPLOAD', 'File is not a valid upload');
|
||||
return false;
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ class BasicAuth {
|
||||
* @return Member $member
|
||||
*/
|
||||
static function requireLogin($realm, $permissionCode = null, $tryUsingSessionLogin = true) {
|
||||
if(!Security::database_is_ready() || (Director::is_cli() && !SapphireTest::is_running_test())) return true;
|
||||
$isRunningTests = (class_exists('SapphireTest', false) && SapphireTest::is_running_test());
|
||||
if(!Security::database_is_ready() || (Director::is_cli() && !$isRunningTests)) return true;
|
||||
|
||||
$member = null;
|
||||
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
|
@ -66,7 +66,7 @@ class EncryptAllPasswordsTask extends BuildTask {
|
||||
* @todo This should really be taken care of by TestRunner
|
||||
*/
|
||||
protected function debugMessage($msg) {
|
||||
if(!SapphireTest::is_running_test()) {
|
||||
if(class_exists('SapphireTest', false) && !SapphireTest::is_running_test()) {
|
||||
Debug::message($msg);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user