diff --git a/.gitignore b/.gitignore index b334e6f6a..f459f215f 100755 --- a/.gitignore +++ b/.gitignore @@ -91,8 +91,9 @@ REVISION .php_cs.cache manifest.json checksum.json -database.json -database_5_7.json +mysql.json +mysql_5_7.json +mariadb_10_x.json settings.json /tests/_log/* diff --git a/gulpfile.js b/gulpfile.js index a456dcaac..1b9425289 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -470,8 +470,9 @@ function release(done) { glob([ '**/*', '!checksum.json', - '!database.json', - '!database_5_7.json', + '!mysql.json', + '!mysql_5_7.json', + '!mariadb_10_x.json', '!settings.json', '!manifest.json', '!.idea/**', @@ -533,7 +534,7 @@ function release(done) { archive.append(shell.exec('php update/structure.php', { silent: true }).stdout, { - name: 'database.json' + name: 'mysql.json' }); // Aggiunta del file per il controllo delle impostazioni diff --git a/include/init/requirements.php b/include/init/requirements.php index 2624fba49..32cfefac9 100755 --- a/include/init/requirements.php +++ b/include/init/requirements.php @@ -247,9 +247,9 @@ if ($database->isInstalled()) { $db = [ 'mysql_version' => [ 'type' => 'version', - 'description' => '5.7.x - 8.0.x', - 'minimum' => '5.7.0', - 'maximum' => '8.0.99', + 'description' => (($database->isMySQL)? '5.7.x - 8.0.x' : '10.x'), + 'minimum' => (($database->isMySQL)? '5.7.0' : '10.1.0'), + 'maximum' => (($database->isMySQL)? '8.0.99' : '10.6.99'), ], 'sort_buffer_size' => [ @@ -355,8 +355,9 @@ foreach ($dirs_to_check as $name => $description) { // File di servizio $files_to_check = [ 'manifest.json' => tr('Necessario per l\'aggiunta a schermata home da terminale (creato al termine della configurazione)'), - 'database_5_7.json' => tr('Necessario per il controllo integrità con database MySQL 5.7.x'), - 'database.json' => tr('Necessario per il controllo integrità con database MySQL 8.0.x'), + 'mariadb_10_x.json' => tr('Necessario per il controllo integrità con database MariaDB 10.x'), + 'mysql_5_7.json' => tr('Necessario per il controllo integrità con database MySQL 5.7.x'), + 'mysql.json' => tr('Necessario per il controllo integrità con database MySQL 8.0.x'), 'checksum.json' => tr('Necessario per il controllo integrità dei files del gestionale'), 'settings.json' => tr('Necessario per il controllo delle impostazioni del gestionale'), ]; @@ -435,7 +436,9 @@ $requirements = [ '_VERSION_' => phpversion(), '_SUPPORTED_' => ((version_compare(phpversion(), $settings['php_version']['minimum'], '>=') && version_compare(phpversion(), $settings['php_version']['maximum'], '<=')) ? '' : ' '.tr('versioni supportate:').' '.$settings['php_version']['description'].''), ]) => $php, - tr('MySQL') => $mysql, + tr('DBMS (_TYPE_)', [ + '_TYPE_' => $database->getType(), + ] ) => $mysql, tr('Percorsi di servizio') => $directories, tr('File di servizio') => $files, tr('Configurazioni') => $config, diff --git a/modules/aggiornamenti/database.php b/modules/aggiornamenti/database.php index 595085746..8a5d30383 100644 --- a/modules/aggiornamenti/database.php +++ b/modules/aggiornamenti/database.php @@ -100,10 +100,20 @@ $(document).ready(function () { return; } -$mysql_min_version = '5.7.0'; -$mysql_max_version = '5.7.99'; +switch ($database->getType()) { + case 'MariaDB': + $file_to_check_database = 'mariadb_10_x.json'; + break; + case 'MySQL': + $mysql_min_version = '5.7.0'; + $mysql_max_version = '5.7.99'; + $file_to_check_database = ((version_compare($database->getMySQLVersion(), $mysql_min_version, '>=') && version_compare($database->getMySQLVersion(), $mysql_max_version, '<=')) ? 'mysql_5_7.json' :'mysql.json'); + break; + default: + $file_to_check_database = 'mysql.json'; + break; +} -$contents = ((version_compare($database->getMySQLVersion(), $mysql_min_version, '>=') && version_compare($database->getMySQLVersion(), $mysql_max_version, '<=')) ? $file_to_check_database = 'database_5_7.json' : $file_to_check_database = 'database.json'); $contents = file_get_contents(base_dir().'/'.$file_to_check_database); $data = json_decode($contents, true); diff --git a/src/Database.php b/src/Database.php index 07d026e43..13e6ad6dd 100755 --- a/src/Database.php +++ b/src/Database.php @@ -205,6 +205,39 @@ class Database extends Util\Singleton return $this->mysql_version; } + /** + * Restituisce il tipo di DBMS. + * + * @return string + */ + public function getType() + { + $ver = $this->fetchArray('SELECT VERSION()'); + if (preg_match('/MariaDB/', $ver[0]['VERSION()'])) { + return 'MariaDB'; + } else { + return 'MySQL'; + } + + } + + + /** + * Controlla il tipo se il DBMS è MySQL. + * + * @return bool + */ + public function isMySQL() + { + $ver = $this->fetchArray('SELECT VERSION()'); + if (preg_match('/MariaDB/', $ver[0]['VERSION()'])) { + return false; + } else { + return true; + } + + } + /** * Restituisce il nome del database a cui si è connessi. *