diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-27 12:10:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 12:10:16 +0200 |
commit | 109ebf318f2f71d6c5f3690da3c16d0b03d982bb (patch) | |
tree | f0a333e9e009d78d59c1e4823f766625bc2bb255 /application | |
parent | af41d5ab5d2bd3ba64d052c997bc6afa6966a63c (diff) | |
parent | 7e3dc0ba98bf019c2804e5c74fb6061b16fb712f (diff) | |
download | Shaarli-109ebf318f2f71d6c5f3690da3c16d0b03d982bb.tar.gz Shaarli-109ebf318f2f71d6c5f3690da3c16d0b03d982bb.tar.zst Shaarli-109ebf318f2f71d6c5f3690da3c16d0b03d982bb.zip |
Merge pull request #1516 from ArthurHoaro/feature/plugin-incompatibility
Better handling of plugin incompatibility
Diffstat (limited to 'application')
-rw-r--r-- | application/container/ContainerBuilder.php | 3 | ||||
-rw-r--r-- | application/container/ShaarliContainer.php | 4 | ||||
-rw-r--r-- | application/front/controller/visitor/ShaarliVisitorController.php | 3 | ||||
-rw-r--r-- | application/plugin/PluginManager.php | 7 |
4 files changed, 13 insertions, 4 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index 4a1a6ea7..58067c99 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php | |||
@@ -152,6 +152,9 @@ class ContainerBuilder | |||
152 | $container['errorHandler'] = function (ShaarliContainer $container): ErrorController { | 152 | $container['errorHandler'] = function (ShaarliContainer $container): ErrorController { |
153 | return new ErrorController($container); | 153 | return new ErrorController($container); |
154 | }; | 154 | }; |
155 | $container['phpErrorHandler'] = function (ShaarliContainer $container): ErrorController { | ||
156 | return new ErrorController($container); | ||
157 | }; | ||
155 | 158 | ||
156 | return $container; | 159 | return $container; |
157 | } | 160 | } |
diff --git a/application/container/ShaarliContainer.php b/application/container/ShaarliContainer.php index c4fe753e..9a9a974a 100644 --- a/application/container/ShaarliContainer.php +++ b/application/container/ShaarliContainer.php | |||
@@ -4,7 +4,6 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Container; | 5 | namespace Shaarli\Container; |
6 | 6 | ||
7 | use http\Cookie; | ||
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 7 | use Shaarli\Bookmark\BookmarkServiceInterface; |
9 | use Shaarli\Config\ConfigManager; | 8 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Feed\FeedBuilder; | 9 | use Shaarli\Feed\FeedBuilder; |
@@ -30,7 +29,7 @@ use Slim\Container; | |||
30 | * @property CookieManager $cookieManager | 29 | * @property CookieManager $cookieManager |
31 | * @property ConfigManager $conf | 30 | * @property ConfigManager $conf |
32 | * @property mixed[] $environment $_SERVER automatically injected by Slim | 31 | * @property mixed[] $environment $_SERVER automatically injected by Slim |
33 | * @property callable $errorHandler Overrides default Slim error display | 32 | * @property callable $errorHandler Overrides default Slim exception display |
34 | * @property FeedBuilder $feedBuilder | 33 | * @property FeedBuilder $feedBuilder |
35 | * @property FormatterFactory $formatterFactory | 34 | * @property FormatterFactory $formatterFactory |
36 | * @property History $history | 35 | * @property History $history |
@@ -39,6 +38,7 @@ use Slim\Container; | |||
39 | * @property NetscapeBookmarkUtils $netscapeBookmarkUtils | 38 | * @property NetscapeBookmarkUtils $netscapeBookmarkUtils |
40 | * @property PageBuilder $pageBuilder | 39 | * @property PageBuilder $pageBuilder |
41 | * @property PageCacheManager $pageCacheManager | 40 | * @property PageCacheManager $pageCacheManager |
41 | * @property callable $phpErrorHandler Overrides default Slim PHP error display | ||
42 | * @property PluginManager $pluginManager | 42 | * @property PluginManager $pluginManager |
43 | * @property SessionManager $sessionManager | 43 | * @property SessionManager $sessionManager |
44 | * @property Thumbnailer $thumbnailer | 44 | * @property Thumbnailer $thumbnailer |
diff --git a/application/front/controller/visitor/ShaarliVisitorController.php b/application/front/controller/visitor/ShaarliVisitorController.php index 47057d97..f17c8ed3 100644 --- a/application/front/controller/visitor/ShaarliVisitorController.php +++ b/application/front/controller/visitor/ShaarliVisitorController.php | |||
@@ -58,10 +58,11 @@ abstract class ShaarliVisitorController | |||
58 | { | 58 | { |
59 | $this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL)); | 59 | $this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL)); |
60 | $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 60 | $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
61 | $this->assignView('plugin_errors', $this->container->pluginManager->getErrors()); | ||
62 | 61 | ||
63 | $this->executeDefaultHooks($template); | 62 | $this->executeDefaultHooks($template); |
64 | 63 | ||
64 | $this->assignView('plugin_errors', $this->container->pluginManager->getErrors()); | ||
65 | |||
65 | return $this->container->pageBuilder->render($template, $this->container->basePath); | 66 | return $this->container->pageBuilder->render($template, $this->container->basePath); |
66 | } | 67 | } |
67 | 68 | ||
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 | } |