From a948564387b3850f780d66d511e1d6d90cbd86c3 Mon Sep 17 00:00:00 2001 From: Bhupesh Pandey <72725957+bhupeshappfoster@users.noreply.github.com> Date: Tue, 6 Sep 2022 19:01:29 +0530 Subject: [PATCH] Release/3.0.1 (#389) * fix: catch error when newsfeed is unreachable * fix: https://github.com/AcclaroInc/craft-translations/issues/387 * update: log for graceful handling of acclaro feed failure * update: change log and bump version Co-authored-by: jdsdev --- .craftplugin | 2 +- CHANGELOG.md | 6 ++++++ src/Translations.php | 11 +++++++---- src/widgets/News.php | 10 +++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.craftplugin b/.craftplugin index 7923b1d5..2128c5c6 100644 --- a/.craftplugin +++ b/.craftplugin @@ -1,7 +1,7 @@ { "pluginName": "Translations for Craft", "pluginDescription": "Drive global growth with simplified translation workflows.", - "pluginVersion": "3.0.0", + "pluginVersion": "3.0.1", "pluginAuthorName": "Acclaro", "pluginVendorName": "Acclaro", "pluginAuthorUrl": "http://www.acclaro.com/", diff --git a/CHANGELOG.md b/CHANGELOG.md index e9a2bc5c..412a3068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 3.0.1 - 2022-09-06 + +### Fixed +- Unhandled exception on plugin installation ([AcclaroInc#387](https://github.com/AcclaroInc/craft-translations/issues/387)) +- Exception opening plugin dashboard when acclaro feed is unavailable. + ## 3.0.0 - 2022-08-24 ### Fixed diff --git a/src/Translations.php b/src/Translations.php index 0bfb3fc9..5259aece 100644 --- a/src/Translations.php +++ b/src/Translations.php @@ -178,10 +178,13 @@ function (DeleteElementEvent $event) { Plugins::class, Plugins::EVENT_AFTER_INSTALL_PLUGIN, function (PluginEvent $event) { - self::$plugin->logHelper->log( - '['. __METHOD__ .'] Plugins::EVENT_AFTER_INSTALL_PLUGIN', - Constants::LOG_LEVEL_INFO - ); + if (self::getInstance()->settings->apiLogging) { + Craft::info( + '[' . __METHOD__ . '] Plugins::EVENT_AFTER_INSTALL_PLUGIN', + 'translations' + ); + } + if ($event->plugin === $this) { $request = Craft::$app->getRequest(); if ($request->isCpRequest) { diff --git a/src/widgets/News.php b/src/widgets/News.php index 7e1c6310..4ce467f5 100644 --- a/src/widgets/News.php +++ b/src/widgets/News.php @@ -12,6 +12,8 @@ use Craft; use craft\base\Widget; +use acclaro\translations\Constants; +use acclaro\translations\Translations; use acclaro\translations\records\WidgetRecord; /** @@ -115,7 +117,13 @@ private function _getArticles(): array 'verify' => false )); - $response = $client->get('feed/'); + try { + $response = $client->get('feed/'); + } catch (\Exception $e) { + Translations::$plugin->logHelper->log("[" . __METHOD__ . "] . $e", Constants::LOG_LEVEL_ERROR); + return []; + } + $data = $response->getBody()->getContents(); $feed = simplexml_load_string($data);