summaryrefslogtreecommitdiffstats
path: root/lib/private/Setup
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2017-02-03 15:38:48 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-04-28 09:35:35 +0200
commitaa22f930181cf66a0610a11ebbe4de7377623444 (patch)
tree1a3303ec2a7424a258f00df5802d055c1540320f /lib/private/Setup
parent3fd75e288cf62551d4e7a300f178a763bd3d406f (diff)
downloadnextcloud-server-aa22f930181cf66a0610a11ebbe4de7377623444.tar.gz
nextcloud-server-aa22f930181cf66a0610a11ebbe4de7377623444.zip
During setup of a mysql database we try to detect if charset 'utf8mb4' can be used
Diffstat (limited to 'lib/private/Setup')
-rw-r--r--lib/private/Setup/MySQL.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index 9998ca401d9..d72a106053f 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -27,6 +27,7 @@
*/
namespace OC\Setup;
+use OC\DB\ConnectionFactory;
use OCP\IDBConnection;
class MySQL extends AbstractDatabase {
@@ -36,6 +37,12 @@ class MySQL extends AbstractDatabase {
//check if the database user has admin right
$connection = $this->connect(['dbname' => null]);
+ // detect mb4
+ if (is_null($this->config->getSValue('mysql.utf8mb4', null)) && $this->supports4ByteCharset($connection)) {
+ $this->config->setValue('mysql.utf8mb4', true);
+ $connection = $this->connect();
+ }
+
$this->createSpecificUser($username, $connection);
//create the database
@@ -162,4 +169,23 @@ class MySQL extends AbstractDatabase {
'dbpassword' => $this->dbPassword,
]);
}
+
+ /**
+ * @param IDBConnection $connection
+ * @return bool
+ */
+ private function supports4ByteCharset(IDBConnection $connection) {
+ foreach (['innodb_file_format' => 'Barracuda', 'innodb_large_prefix' => 'ON', 'innodb_file_per_table' => 'ON'] as $var => $val) {
+ $result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'");
+ $rows = $result->fetch();
+ $result->closeCursor();
+ if ($rows === false) {
+ return false;
+ }
+ if (strcasecmp($rows['Value'], $val) === 0) {
+ return false;
+ }
+ }
+ return true;
+ }
}