ENHANCEMENT Checking for $_FILE_TO_URL_MAPPING in DevelopmentAdmin if called in CLI mode to avoid nasty bugs e.g. during FunctionalTest sessions (Example: Controller stack was failing for some weird reason in LeftAndMainTest)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68508 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-12-12 01:17:22 +00:00 committed by Sam Minnee
parent 82e7f65c81
commit c92163198d

View File

@ -16,6 +16,38 @@ class DevelopmentAdmin extends Controller {
'$Action//$Action/$ID' => 'handleAction',
);
function init() {
parent::init();
// check for valid url mapping
// lacking this information can cause really nasty bugs,
// e.g. when running Director::test() from a FunctionalTest instance
global $_FILE_TO_URL_MAPPING;
if(Director::is_cli()) {
if(isset($_FILE_TO_URL_MAPPING)) {
$fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
while($testPath && $testPath != "/") {
$matched = false;
if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
$matched = true;
break;
}
$testPath = dirname($testPath);
}
if(!$matched) {
echo 'Warning: You probably want to define '.
'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
}
}
else {
echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in '.
'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki' . "\n";
}
}
}
function index() {
$actions = array(
"build" => "Build/rebuild this environment (formerly db/build). Call this whenever you have updated your project sources",