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.:
This commit is contained in:
ArthurHoaro 2020-08-27 12:04:36 +02:00
parent af41d5ab5d
commit 7e3dc0ba98
8 changed files with 91 additions and 51 deletions
application/plugin

View file

@ -116,7 +116,12 @@ class PluginManager
$hookFunction = $this->buildHookName($hook, $plugin);
if (function_exists($hookFunction)) {
$data = call_user_func($hookFunction, $data, $this->conf);
try {
$data = call_user_func($hookFunction, $data, $this->conf);
} catch (\Throwable $e) {
$error = $plugin . t(' [plugin incompatibility]: ') . $e->getMessage();
$this->errors = array_unique(array_merge($this->errors, [$error]));
}
}
}
}