summaryrefslogtreecommitdiff
path: root/core/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-03-19 02:35:51 +0000
committerBharat Mediratta <bharat@menalto.com>2009-03-19 02:35:51 +0000
commit61d8a143eaf7478b15edf554f2ccaada75c8bd9d (patch)
tree182a026565370e42d22db9ae15cc9fcbed8828c9 /core/controllers
parent0b721258f42c0775d1fb90966a82fe3a81763e00 (diff)
Rejigger the way we do reinstalls while Kohana is running.
core_installer::install() now takes an $initial_install param that allows us to enforce that we're doing a clean install. Use this in both the scaffolding and the unit test code. Greatly simplify the scaffolding uninstall/reinstall code.
Diffstat (limited to 'core/controllers')
-rw-r--r--core/controllers/scaffold.php55
1 files changed, 12 insertions, 43 deletions
diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php
index 1c2ce896..63b00f2d 100644
--- a/core/controllers/scaffold.php
+++ b/core/controllers/scaffold.php
@@ -273,57 +273,26 @@ class Scaffold_Controller extends Template_Controller {
}
}
- function uninstall($module_name, $redirect=true) {
- $clean = true;
- if ($module_name == "core") {
- // We have to uninstall all other modules first, else their tables, etc don't
- // get cleaned up.
- $old_handler = set_error_handler(array("scaffold_Controller", "_error_handler"));
- try {
- foreach (ORM::factory("module")->find_all() as $module) {
- if ($module->name != "core" && $module->version) {
- try {
- call_user_func(array("{$module->name}_installer", "uninstall"));
- } catch (Exception $e) {
- print $e;
- }
- }
- }
- core_installer::uninstall();
- } catch (Exception $e) {
- print $e;
- }
+ public function package() {
+ $this->auto_render = false;
+ $db = Database::instance();
- // Since we're in a state of flux, it's possible that other stuff went wrong with the
- // uninstall, so back off and nuke it from orbit. It's the only way to be sure.
- $db = Database::instance();
- foreach ($db->list_tables() as $table) {
+ // Drop all tables
+ foreach ($db->list_tables() as $table) {
$db->query("DROP TABLE IF EXISTS `$table`");
- }
- set_error_handler($old_handler);
- } else {
- module::uninstall($module_name);
}
- if ($redirect) {
- url::redirect("scaffold");
- }
- }
-
- public function package() {
- $this->auto_render = false;
- // Cleanly uninstalling and reinstalling within the same request requires us to do the "cache
- // invalidation" cha-cha. It's a dance of many steps.
- $this->uninstall("core", false);
module::$module_names = array();
module::$modules = array();
- Database::instance()->clear_cache();
- $this->install("core", false);
+ $db->clear_cache();
+
+ core_installer::install(true);
module::load_modules();
- foreach (array("core", "user", "comment", "info",
- "rss", "search", "slideshow", "tag") as $module_name) {
- $this->install($module_name, false);
+
+ foreach (array("user", "comment", "info", "rss",
+ "search", "slideshow", "tag") as $module_name) {
+ module::install($module_name);
}
url::redirect("scaffold/dump_database");
}