aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Extension.php6
-rw-r--r--lib/Minz/ExtensionManager.php8
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php
index 25cbe2091..d03db8bde 100644
--- a/lib/Minz/Extension.php
+++ b/lib/Minz/Extension.php
@@ -91,6 +91,10 @@ abstract class Minz_Extension {
$this->is_enabled = true;
}
+ final public function disable(): void {
+ $this->is_enabled = false;
+ }
+
/**
* Return if the extension is currently enabled.
*
@@ -253,6 +257,8 @@ abstract class Minz_Extension {
switch ($type) {
case 'system': return FreshRSS_Context::hasSystemConf();
case 'user': return FreshRSS_Context::hasUserConf();
+ default:
+ return false;
}
}
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 84a6fc09f..fea1f5879 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -268,7 +268,13 @@ final class Minz_ExtensionManager {
spl_autoload_register([$ext, 'autoload']);
}
$ext->enable();
- $ext->init();
+ try {
+ $ext->init();
+ } catch (Minz_Exception $e) { // @phpstan-ignore catch.neverThrown (Thrown by extensions)
+ Minz_Log::warning('Error while enabling extension ' . $ext->getName() . ': ' . $e->getMessage());
+ $ext->disable();
+ unset(self::$ext_list_enabled[$ext_name]);
+ }
}
}