From 1d2b5b80b38d9249d9217cd49e8e0154885ee515 Mon Sep 17 00:00:00 2001 From: Alwin Drenth Date: Tue, 23 Nov 2021 14:25:42 +0100 Subject: [PATCH] Fix database error --- CHANGELOG.md | 4 ++++ Plugin.php | 20 ++++++++++++++------ updates/version.yaml | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29253af..2032f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 2.5.13 + +* Fix database error when cache is being cleared before installation of plugin. + ## 2.5.12 * Fix strpos() type error. diff --git a/Plugin.php b/Plugin.php index e8f327d..91fb6e5 100644 --- a/Plugin.php +++ b/Plugin.php @@ -365,9 +365,13 @@ private function registerEventListeners(): void * When one or more redirects have been changed. */ Event::listen('vdlp.redirect.changed', static function (array $redirectIds): void { - /** @var PublishManagerInterface $publishManager */ - $publishManager = resolve(PublishManagerInterface::class); - $publishManager->publish(); + try { + /** @var PublishManagerInterface $publishManager */ + $publishManager = resolve(PublishManagerInterface::class); + $publishManager->publish(); + } catch (Throwable $throwable) { + // @ignoreException + } }); /* @@ -376,9 +380,13 @@ private function registerEventListeners(): void * Re-publish all redirect if cache has been cleared. */ Event::listen('cache:cleared', static function (): void { - /** @var PublishManagerInterface $publishManager */ - $publishManager = resolve(PublishManagerInterface::class); - $publishManager->publish(); + try { + /** @var PublishManagerInterface $publishManager */ + $publishManager = resolve(PublishManagerInterface::class); + $publishManager->publish(); + } catch (Throwable $throwable) { + // @ignoreException + } }); } } diff --git a/updates/version.yaml b/updates/version.yaml index daea95e..f27f200 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -95,3 +95,5 @@ - "Minor fixes -- See: https://github.com/vdlp/oc-redirect-plugin/releases/tag/2.5.11" 2.5.12: - "Fix strpos() type error" +2.5.13: + - "Fix database error when cache is being cleared before installation of plugin."