BUGFIX: #3481 - Check if classes exist before trying to instantiate a singleton on database build, to work around stale manifest errors

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@71846 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2009-02-15 22:22:07 +00:00 committed by Sam Minnee
parent 21bf2a82b1
commit 649ce069e7

View File

@ -158,13 +158,16 @@ class DatabaseAdmin extends Controller {
$conn = DB::getConn();
$conn->beginSchemaUpdate();
foreach($dataClasses as $dataClass) {
$SNG = singleton($dataClass);
if($testMode || !($SNG instanceof TestOnly)) {
if(!$quiet) {
if(Director::is_cli()) echo " * $dataClass\n";
else echo "<li>$dataClass</li>\n";
// Check if class exists before trying to instantiate - this sidesteps any manifest weirdness
if(class_exists($dataClass)) {
$SNG = singleton($dataClass);
if($testMode || !($SNG instanceof TestOnly)) {
if(!$quiet) {
if(Director::is_cli()) echo " * $dataClass\n";
else echo "<li>$dataClass</li>\n";
}
$SNG->requireTable();
}
$SNG->requireTable();
}
}
$conn->endSchemaUpdate();
@ -176,9 +179,9 @@ class DatabaseAdmin extends Controller {
}
foreach($dataClasses as $dataClass) {
// Check if class exists before trying to instantiate - this sidesteps any manifest weirdness
// Test_ indicates that it's the data class is part of testing system
if(strpos($dataClass,'Test_') === false) {
if(strpos($dataClass,'Test_') === false && class_exists($dataClass)) {
if(!$quiet) {
if(Director::is_cli()) echo " * $dataClass\n";
else echo "<li>$dataClass</li>\n";
@ -265,4 +268,4 @@ class DatabaseAdmin extends Controller {
}
?>
?>