]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/plugin/PluginManager.php
Better handling of plugin incompatibility
[github/shaarli/Shaarli.git] / application / plugin / PluginManager.php
index 591a918098ee46a8d22d9643ebabbe7a9f0756b9..2d93cb3a2173c58bada5803b8ca4fd522819991f 100644 (file)
@@ -108,11 +108,20 @@ class PluginManager
             $data['_LOGGEDIN_'] = $params['loggedin'];
         }
 
+        if (isset($params['basePath'])) {
+            $data['_BASE_PATH_'] = $params['basePath'];
+        }
+
         foreach ($this->loadedPlugins as $plugin) {
             $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]));
+                }
             }
         }
     }