Merge pull request #16918 from mattwire/smartyerrorevent
[civicrm-core.git] / Civi / Install / Requirements.php
index e7c9581106cbbe902167211a8b4d886d4c28ea43..586a0c75d2de3c2d458e00a97740305cf567c7b1 100644 (file)
@@ -58,6 +58,9 @@ class Requirements {
    *   An array of check summaries. Each array contains the keys 'title', 'severity', and 'details'.
    */
   public function checkAll(array $config) {
+    if (!class_exists('\CRM_Utils_SQL_TempTable')) {
+      require_once dirname(__FILE__) . '/../../CRM/Utils/SQL/TempTable.php';
+    }
     return array_merge($this->checkSystem($config['file_paths']), $this->checkDatabase($config['db_config']));
   }
 
@@ -291,7 +294,7 @@ class Requirements {
    * @return array
    */
   public function checkMysqlVersion(array $db_config) {
-    $min = '5.1';
+    $min = \CRM_Upgrade_Incremental_General::MIN_INSTALL_MYSQL_VER;
     $results = [
       'title' => 'CiviCRM MySQL Version',
       'severity' => $this::REQUIREMENT_OK,
@@ -304,7 +307,8 @@ class Requirements {
       return $results;
     }
 
-    if (version_compare($info, $min) == -1) {
+    $versionDetails = mysqli_query($conn, 'SELECT version() as version')->fetch_assoc();
+    if (version_compare($versionDetails['version'], $min) == -1) {
       $results['severity'] = $this::REQUIREMENT_ERROR;
       $results['details'] = "MySQL version is {$info}; minimum required is {$min}";
       return $results;
@@ -373,15 +377,15 @@ class Requirements {
       $results['details'] = "Could not select the database";
       return $results;
     }
-
-    $r = mysqli_query($conn, 'CREATE TEMPORARY TABLE civicrm_install_temp_table_test (test text)');
+    $temporaryTableName = \CRM_Utils_SQL_TempTable::build()->setCategory('install')->getName();
+    $r = mysqli_query($conn, 'CREATE TEMPORARY TABLE ' . $temporaryTableName . ' (test text)');
     if (!$r) {
       $results['severity'] = $this::REQUIREMENT_ERROR;
       $results['details'] = "Database does not support creation of temporary tables";
       return $results;
     }
 
-    mysqli_query($conn, 'DROP TEMPORARY TABLE civicrm_install_temp_table_test');
+    mysqli_query($conn, 'DROP TEMPORARY TABLE ' . $temporaryTableName);
     return $results;
   }
 
@@ -624,7 +628,7 @@ class Requirements {
     mysqli_query($conn, 'DROP TABLE civicrm_utf8mb4_test');
 
     // Ensure that the MySQL driver supports utf8mb4 encoding.
-    $version = mysqli_get_client_info($conn);
+    $version = mysqli_get_client_info();
     if (strpos($version, 'mysqlnd') !== FALSE) {
       // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
       $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);