diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-03-03 09:05:56 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-03-03 09:05:56 +0000 |
| commit | 99d5bb9bdbbbef95ed1019554d0a9e9e200c8544 (patch) | |
| tree | 109742c2ffd0dd0dd9771c7531163d8f7904dda7 /app/Module.php | |
| parent | 0fd21fda61c8bff026db9b2a6093f2ec7967d7a8 (diff) | |
| download | webtrees-99d5bb9bdbbbef95ed1019554d0a9e9e200c8544.tar.gz webtrees-99d5bb9bdbbbef95ed1019554d0a9e9e200c8544.tar.bz2 webtrees-99d5bb9bdbbbef95ed1019554d0a9e9e200c8544.zip | |
Fix #455 - better error handling for custom modules
Diffstat (limited to 'app/Module.php')
| -rw-r--r-- | app/Module.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/Module.php b/app/Module.php index 4ef2f4b180..2f51cb2f50 100644 --- a/app/Module.php +++ b/app/Module.php @@ -194,8 +194,10 @@ abstract class Module { $module = include WT_ROOT . WT_MODULES_DIR . $module_name . '/module.php'; if ($module instanceof Module) { $modules[$module->getName()] = $module; + } else { + throw new \Exception; } - } catch (\ErrorException $ex) { + } catch (\Exception $ex) { // Module has been deleted or is broken? Disable it. Log::addConfigurationLog("Module {$module_name} is missing or broken - disabling it"); Database::prepare( @@ -235,17 +237,16 @@ abstract class Module { 'access_level' => $access_level, ))->fetchOneColumn(); - $active_modules = self::getActiveModules(); - $array = array(); foreach ($module_names as $module_name) { $interface = __NAMESPACE__ . '\Module' . ucfirst($component) . 'Interface'; - if ($active_modules[$module_name] instanceof $interface) { - $array[$module_name] = $active_modules[$module_name]; + $module = self::getModuleByName($module_name); + if ($module instanceof $interface) { + $array[$module_name] = $module; } } - // The order of menus/sidebars/tabs is defined by the user. Others are sorted by name. + // The order of menus/sidebars/tabs is defined in the database. Others are sorted by name. if ($component !== 'menu' && $component !== 'sidebar' && $component !== 'tab') { uasort($array, function(Module $x, Module $y) { return I18N::strcasecmp($x->getTitle(), $y->getTitle()); @@ -433,7 +434,7 @@ abstract class Module { )->execute(array($module->getName(), $module->defaultAccessLevel())); } } catch (\Exception $ex) { - // Probably an old third-party module. + // Old or invalid module? } } |
