Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit bbc8a69

Browse files
author
Charles Ma
committed
BUG: fixed bug #193 MIDAS now detect if the database if empty
1 parent a535a3c commit bbc8a69

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

core/controllers/InstallController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ class InstallController extends AppController
2525
*/
2626
function init()
2727
{
28+
if(isset($_GET['reset']))
29+
{
30+
$db = Zend_Registry::get('dbAdapter');
31+
$table = $db->listTables();
32+
if(empty($table) && file_exists(BASE_PATH."/core/configs/database.local.ini"))
33+
{
34+
unlink(BASE_PATH."/core/configs/database.local.ini");
35+
if(file_exists(BASE_PATH."/core/configs/application.local.ini"))
36+
{
37+
unlink(BASE_PATH."/core/configs/application.local.ini");
38+
}
39+
}
40+
}
2841
if(file_exists(BASE_PATH."/core/configs/database.local.ini") && file_exists(BASE_PATH."/core/configs/application.local.ini"))
2942
{
3043
throw new Zend_Exception("Midas is already installed.");

core/controllers/components/NotifyErrorComponent.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,23 @@ public function fatalEror($logger, $mailer)
112112
{
113113
return;
114114
}
115-
header('content-type: text/plain');
115+
116116
if(count(ob_list_handlers()) > 0)
117117
{
118118
ob_clean();
119119
}
120+
121+
$db = Zend_Registry::get('dbAdapter');
122+
$table = $db->listTables();
123+
if(file_exists(BASE_PATH.'/core/configs/database.local.ini') && empty($table))
124+
{
125+
$fc = Zend_Controller_Front::getInstance();
126+
$webroot = $fc->getBaseUrl();
127+
echo "MIDAS is not installed. <a href='".$webroot."/install?reset=true'>Click here to reset MIDAS and go to the installation page.</a>";
128+
return;
129+
}
130+
131+
header('content-type: text/plain');
120132
echo $this->getFatalErrorMessage($e);
121133
}
122134
$logger->crit($this->getFatalErrorMessage($e));

0 commit comments

Comments
 (0)