ENHANCEMENT: Database will fix itself if you view the site and the database doesn't exist

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@72497 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-03-05 04:43:37 +00:00
parent d904c0b8d0
commit a1e48eff8e
3 changed files with 23 additions and 1 deletions

View File

@ -13,6 +13,14 @@ class ModelAsController extends Controller implements NestedController {
$this->urlParams = $request->allParams();
$this->init();
// If the basic database hasn't been created, then build it.
if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
$this->response = new HTTPResponse();
$this->redirect("dev/build?returnURL=" . urlencode($_GET['url']));
return $this->response;
}
$result = $this->getNestedController();
if(is_object($result) && $result instanceOf RequestHandler) {

View File

@ -19,6 +19,13 @@ class RootURLController extends Controller {
$this->init();
// If the basic database hasn't been created, then build it.
if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) {
$this->response = new HTTPResponse();
$this->redirect("dev/build?returnURL=");
return $this->response;
}
$controller = new ModelAsController();
$request = new HTTPRequest("GET", self::get_homepage_urlsegment().'/', $request->getVars(), $request->postVars());

View File

@ -78,7 +78,14 @@ class DatabaseAdmin extends Controller {
ManifestBuilder::create_manifest_file();
require(MANIFEST_FILE);
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
if(isset($_GET['returnURL'])) {
echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
$this->doBuild(true);
echo "<p>Done!</p>";
Director::redirect($_GET['returnURL']);
} else {
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
}
}
/**