From e4e971a18faa8e0893d80156a27979210f6ba7f1 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Sun, 19 Aug 2007 23:47:49 +0000 Subject: [PATCH] Fix db/build problems when creating a new database git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40473 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/ManifestBuilder.php | 24 ++++++++++++++---------- core/model/DatabaseAdmin.php | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/ManifestBuilder.php b/core/ManifestBuilder.php index 2d882f117..f5f436823 100644 --- a/core/ManifestBuilder.php +++ b/core/ManifestBuilder.php @@ -119,17 +119,14 @@ class ManifestBuilder { $manifest .= "\$_CSS_MANIFEST = " . var_export($cssManifest, true) . ";\n"; DB::connect($databaseConfig); - if(DB::isActive()) { - // Database manifest - $allClasses = ManifestBuilder::allClasses($classManifest); + // Database manifest + $allClasses = ManifestBuilder::allClasses($classManifest); - $manifest .= "\$_ALL_CLASSES = " . var_export($allClasses, true) . ";\n"; + $manifest .= "\$_ALL_CLASSES = " . var_export($allClasses, true) . ";\n"; + + global $_ALL_CLASSES; + $_ALL_CLASSES = $allClasses; - global $_ALL_CLASSES; - $_ALL_CLASSES = $allClasses; - } else { - if(!isset($_REQUEST['from_installer'])) echo '
  • Waiting until the database is created before compiling the manifest
  • '; - } // Write manifest to disk $manifest = ""; @@ -201,7 +198,14 @@ class ManifestBuilder { $b = basename($file); if($b != 'cli-script.php' && $b != 'main.php') include_once($file); } - $tables = DB::getConn()->tableList(); + + if(DB::isActive()) { + $tables = DB::getConn()->tableList(); + } else { + $tables = array(); + } + + $allClasses['hastable'] = array(); // Build a map of classes and their subclasses $_classes = get_declared_classes(); diff --git a/core/model/DatabaseAdmin.php b/core/model/DatabaseAdmin.php index 84b2050c4..777cd8d16 100644 --- a/core/model/DatabaseAdmin.php +++ b/core/model/DatabaseAdmin.php @@ -136,6 +136,7 @@ class DatabaseAdmin extends Controller { echo '

    Creating database

    '; } DB::createDatabase(); + // ManifestBuilder::compileManifest(); } // Get all our classes @@ -149,7 +150,7 @@ class DatabaseAdmin extends Controller { if(!$quiet) { echo '

    Creating database tables

    '; } - + $conn->beginSchemaUpdate(); foreach($dataClasses as $dataClass) { // Test_ indicates that it's the data class is part of testing system