diff options
author | mamouneyya <mamoun.diraneyya@gmail.com> | 2010-08-31 18:04:21 +0300 |
---|---|---|
committer | mamouneyya <mamoun.diraneyya@gmail.com> | 2010-08-31 18:04:21 +0300 |
commit | 0b6664e8f9d19df025739bc4a0cf1821563d6b3d (patch) | |
tree | 5b1de2331d4a9d0eb8d97bbb74be6d794d6260a1 /modules/gallery/helpers/module.php | |
parent | 0a128bab0a788288c5291491a68bd1c9ab432825 (diff) | |
parent | 23d59dec7240dfa4bffe9d88f46a848e76ce0134 (diff) |
Merge remote branch 'gallery3/master'
Diffstat (limited to 'modules/gallery/helpers/module.php')
-rw-r--r-- | modules/gallery/helpers/module.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 5134c7b3..ca6651f1 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -166,6 +166,16 @@ class module_Core { } else { module::set_version($module_name, 1); } + + // Set the weight of the new module, which controls the order in which the modules are + // loaded. By default, new modules are installed at the end of the priority list. Since the + // id field is monotonically increasing, the easiest way to guarantee that is to set the weight + // the same as the id. We don't know that until we save it for the first time + $module = ORM::factory("module")->where("name", "=", $module_name)->find(); + if ($module->loaded()) { + $module->weight = $module->id; + $module->save(); + } module::load_modules(); // Now the module is installed but inactive, so don't leave it in the active path @@ -314,7 +324,15 @@ class module_Core { self::$modules = array(); self::$active = array(); $kohana_modules = array(); - foreach (ORM::factory("module")->find_all() as $module) { + + // In version 32 we introduced a weight column so we can specify the module order + // If we try to use that blindly, we'll break earlier versions before they can even + // run the upgrader. + $modules = module::get_version("gallery") < 32 ? + ORM::factory("module")->find_all(): + ORM::factory("module")->order_by("weight")->find_all(); + + foreach ($modules as $module) { self::$modules[$module->name] = $module; if (!$module->active) { continue; |