diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-27 12:04:36 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-08-27 12:04:36 +0200 |
commit | 7e3dc0ba98bf019c2804e5c74fb6061b16fb712f (patch) | |
tree | f0a333e9e009d78d59c1e4823f766625bc2bb255 /application/plugin/PluginManager.php | |
parent | af41d5ab5d2bd3ba64d052c997bc6afa6966a63c (diff) | |
download | Shaarli-7e3dc0ba98bf019c2804e5c74fb6061b16fb712f.tar.gz Shaarli-7e3dc0ba98bf019c2804e5c74fb6061b16fb712f.tar.zst Shaarli-7e3dc0ba98bf019c2804e5c74fb6061b16fb712f.zip |
Better handling of plugin incompatibility
If a PHP is raised while executing plugin hook, Shaarli will display an error instead of rendering the error page (or just ending in fatal error for default hooks).
Also added phpErrorHandler which is handled differently that regular errorHandler by Slim.:
Diffstat (limited to 'application/plugin/PluginManager.php')
-rw-r--r-- | application/plugin/PluginManager.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/application/plugin/PluginManager.php b/application/plugin/PluginManager.php index b3e8b2f8..2d93cb3a 100644 --- a/application/plugin/PluginManager.php +++ b/application/plugin/PluginManager.php | |||
@@ -116,7 +116,12 @@ class PluginManager | |||
116 | $hookFunction = $this->buildHookName($hook, $plugin); | 116 | $hookFunction = $this->buildHookName($hook, $plugin); |
117 | 117 | ||
118 | if (function_exists($hookFunction)) { | 118 | if (function_exists($hookFunction)) { |
119 | $data = call_user_func($hookFunction, $data, $this->conf); | 119 | try { |
120 | $data = call_user_func($hookFunction, $data, $this->conf); | ||
121 | } catch (\Throwable $e) { | ||
122 | $error = $plugin . t(' [plugin incompatibility]: ') . $e->getMessage(); | ||
123 | $this->errors = array_unique(array_merge($this->errors, [$error])); | ||
124 | } | ||
120 | } | 125 | } |
121 | } | 126 | } |
122 | } | 127 | } |