diff options
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-rw-r--r-- | appinfo/install.php | 18 | ||||
-rw-r--r-- | appinfo/update.php | 2 | ||||
-rw-r--r-- | docs/externalapi/Legacy.md | 4 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 2 | ||||
-rw-r--r-- | lib/Service/StatusService.php | 20 | ||||
-rw-r--r-- | templates/part.content.php | 2 | ||||
-rw-r--r-- | templates/part.content.warnings.php (renamed from templates/part.content.cronwarning.php) | 19 |
9 files changed, 48 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 102517efc..e123acd99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Changelog All notable changes to this project will be documented in this file. -## 11.0.2 +## 11.0.3 + +### Fixed +- Display database charset warning inside the app instead of failing installation/update + +## 11.0.2 ### Fixed diff --git a/appinfo/info.xml b/appinfo/info.xml index fae408c05..00ceb5aab 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -8,7 +8,7 @@ Before you update to a new version, [check the changelog](https://github.com/nextcloud/news/blob/master/CHANGELOG.md) to avoid surprises. **Important**: To enable feed updates you will need to enable either [Nextcloud system cron](https://docs.nextcloud.com/server/10/admin_manual/configuration_server/background_jobs_configuration.html#cron) or use [an updater](https://github.com/nextcloud/news-updater) which uses the built in update API and disable cron updates. More information can be found [in the README](https://github.com/nextcloud/news).]]></description> - <version>11.0.2</version> + <version>11.0.3</version> <licence>agpl</licence> <author>Bernhard Posselt</author> <author>Alessandro Cosentino</author> diff --git a/appinfo/install.php b/appinfo/install.php deleted file mode 100644 index 3bf3cde1f..000000000 --- a/appinfo/install.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -namespace OCA\News\AppInfo; - -use Exception; -use OC; -use Doctrine\DBAL\Platforms\MySqlPlatform; - -// fail early when an incorrectly configured mysql instances is found to -// prevent update errors and data loss -$charset = OC::$server->getDatabaseConnection()->getParams()['charset']; -$platform = OC::$server->getDatabaseConnection()->getDatabasePlatform(); -if ($platform instanceof MySqlPlatform && $charset !== 'utf8mb4') { - $msg = 'App can not be installed because database MySql/MariaDb uses a ' . - 'non UTF8 charset: ' . $charset .'. Learn more on how to migrate ' . - 'your database to utf8mb4 after making a backup at ' . - 'https://dba.stackexchange.com/a/21684'; - throw new Exception($msg); -}
\ No newline at end of file diff --git a/appinfo/update.php b/appinfo/update.php deleted file mode 100644 index 7f0a9a4c5..000000000 --- a/appinfo/update.php +++ /dev/null @@ -1,2 +0,0 @@ -<?php -require_once __DIR__ . '/install.php';
\ No newline at end of file diff --git a/docs/externalapi/Legacy.md b/docs/externalapi/Legacy.md index 7427e2e5b..28809d2c6 100644 --- a/docs/externalapi/Legacy.md +++ b/docs/externalapi/Legacy.md @@ -732,7 +732,8 @@ This API can be used to display warnings and errors in your client if the web ap { "version": "5.2.4", "warnings": { - "improperlyConfiguredCron": false // if true the webapp will fail to update the feeds correctly + "improperlyConfiguredCron": false, // if true the webapp will fail to update the feeds correctly + "incorrectDbCharset": false } } ``` @@ -746,6 +747,7 @@ You should show the following warning and the link should be clickable: The News App updater is improperly configured and you will lose updates. See http://hisdomain.com/index.php/apps/news for instructions on how to fix it. +If **incorrectDbCharset** is true you should display a warning that database charset is set up incorrectly and updates with unicode characters might fail # User diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 3d1db0d57..22f79952a 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -68,7 +68,7 @@ class PageController extends Controller { public function index() { $status = $this->statusService->getStatus(); $response = new TemplateResponse($this->appName, 'index', [ - 'cronWarning' => $status['warnings']['improperlyConfiguredCron'], + 'warnings' => $status['warnings'], 'url_generator' => $this->urlGenerator ]); diff --git a/lib/Service/StatusService.php b/lib/Service/StatusService.php index 6233d8d62..066c63ff3 100644 --- a/lib/Service/StatusService.php +++ b/lib/Service/StatusService.php @@ -13,7 +13,10 @@ namespace OCA\News\Service; +use Doctrine\DBAL\Platforms\MySqlPlatform; + use OCP\IConfig; +use OCP\IDBConnection; use OCA\News\Config\Config; @@ -23,11 +26,17 @@ class StatusService { private $settings; private $config; private $appName; + /** + * @var IDBConnection + */ + private $connection; - public function __construct(IConfig $settings, Config $config, $AppName) { + public function __construct(IConfig $settings, IDBConnection $connection, + Config $config, $AppName) { $this->settings = $settings; $this->config = $config; $this->appName = $AppName; + $this->connection = $connection; } public function isProperlyConfigured() { @@ -49,9 +58,16 @@ class StatusService { return [ 'version' => $version, 'warnings' => [ - 'improperlyConfiguredCron' => !$this->isProperlyConfigured() + 'improperlyConfiguredCron' => !$this->isProperlyConfigured(), + 'incorrectDbCharset' => $this->hasIncorrectCharset() ] ]; } + public function hasIncorrectCharset() { + $charset = $this->connection->getParams()['charset']; + $platform = $this->connection->getDatabasePlatform(); + return $platform instanceof MySqlPlatform && $charset !== 'utf8mb4'; + } + }
\ No newline at end of file diff --git a/templates/part.content.php b/templates/part.content.php index 873c71bdc..844588c4f 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -1,4 +1,4 @@ -<?php print_unescaped($this->inc('part.content.cronwarning')) ?> +<?php print_unescaped($this->inc('part.content.warnings')) ?> <div news-auto-focus="#app-content" id="articles" diff --git a/templates/part.content.cronwarning.php b/templates/part.content.warnings.php index 62052b331..e4ac09652 100644 --- a/templates/part.content.cronwarning.php +++ b/templates/part.content.warnings.php @@ -1,4 +1,4 @@ -<?php if ($_['cronWarning']) { ?> +<?php if ($_['warnings']['improperlyConfiguredCron']) { ?> <news-instant-notification id="cron-warning"> <p><?php p($l->t('Ajax or Web cron mode detected! Your feeds will not be updated!')); ?></p> <ul> @@ -23,3 +23,20 @@ </ul> </news-instant-notification> <?php }; ?> + +<?php if ($_['warnings']['incorrectDbCharset']) { ?> + <news-instant-notification id="cron-warning"> + <p><?php p($l->t('Incorrect MySql/MariaDb database charset detected!')); ?></p> + <ul> + <li> + <a href="https://dba.stackexchange.com/a/21684" + target="_blank" + rel="noreferrer"> + <?php + p($l->t('Learn on how to convert your database to utf8mb4')); + ?> + </a> + </li> + </ul> + </news-instant-notification> +<?php }; ?>
\ No newline at end of file |