diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2017-05-24 20:22:18 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2017-05-24 20:22:28 +0200 |
commit | 29092e992b2631345b9fcef2bd02eec3d2bf18ce (patch) | |
tree | 568aaa8abe5bd086fc5572367fda58ea9b257343 /appinfo/install.php | |
parent | e1d27b5c9e02b0201bcd2f485fdcd27ae64a726d (diff) |
Fail early for incorrectly configured instances
Diffstat (limited to 'appinfo/install.php')
-rw-r--r-- | appinfo/install.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/appinfo/install.php b/appinfo/install.php new file mode 100644 index 000000000..887821ee7 --- /dev/null +++ b/appinfo/install.php @@ -0,0 +1,18 @@ +<?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 at ' . + 'https://dba.stackexchange.com/questions/8239/how-to-easily-convert-utf8-tables-to-utf8mb4-in-mysql-5-5'; + throw new Exception($msg); +}
\ No newline at end of file |