From 649ce069e7623eaa5e5b0b4079bddd61568597cc Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Sun, 15 Feb 2009 22:22:07 +0000 Subject: [PATCH] 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 --- core/model/DatabaseAdmin.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/model/DatabaseAdmin.php b/core/model/DatabaseAdmin.php index 107bd8f15..b231b7bba 100644 --- a/core/model/DatabaseAdmin.php +++ b/core/model/DatabaseAdmin.php @@ -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 "
  • $dataClass
  • \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 "
  • $dataClass
  • \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 "
  • $dataClass
  • \n"; @@ -265,4 +268,4 @@ class DatabaseAdmin extends Controller { } -?> \ No newline at end of file +?>