Merge pull request #13258 from eileenmcnaughton/isam
[civicrm-core.git] / CRM / Utils / SQL.php
index fb4c41273b068f0113ef6d6618be366dbcd65310..0104fd50c75e23ef461c99c758b86691d0c2ac99 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
  * Just another collection of static utils functions.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
  */
 class CRM_Utils_SQL {
 
@@ -69,11 +69,22 @@ class CRM_Utils_SQL {
   }
 
   /**
-   * Does this System support the MYSQL mode ONLY_FULL_GROUP_BY
+   * Checks if this system enforce the MYSQL mode ONLY_FULL_GROUP_BY.
+   * This function should be named supportsAnyValueAndEnforcesFullGroupBY(),
+   * but should be deprecated instead.
+   *
    * @return mixed
+   * @deprecated
    */
   public static function supportsFullGroupBy() {
-    return version_compare(CRM_Core_DAO::singleValueQuery('SELECT VERSION()'), '5.7', '>=');
+    // CRM-21455 MariaDB 10.2 does not support ANY_VALUE
+    $version = CRM_Core_DAO::singleValueQuery('SELECT VERSION()');
+
+    if (stripos($version, 'mariadb') !== FALSE) {
+      return FALSE;
+    }
+
+    return version_compare($version, '5.7', '>=');
   }
 
   /**
@@ -101,9 +112,6 @@ class CRM_Utils_SQL {
    * @return bool
    */
   public static function isGroupByModeInDefault() {
-    if (!self::supportsFullGroupBy()) {
-      return FALSE;
-    }
     $sqlModes = explode(',', CRM_Core_DAO::singleValueQuery('SELECT @@global.sql_mode'));
     if (!in_array('ONLY_FULL_GROUP_BY', $sqlModes)) {
       return FALSE;
@@ -111,4 +119,19 @@ class CRM_Utils_SQL {
     return TRUE;
   }
 
+  /**
+   * Is the Database set up to handle acceents.
+   * @warning This function was introduced in attempt to determine the reason why the test getInternationalStrings was failing on ubu1604 but passing on ubu1204-5
+   * This function should not be used as the basis of further work as the reasoning is not perfact and is giving false failures.
+   * @return bool
+   */
+  public static function supportStorageOfAccents() {
+    $charSetDB = CRM_Core_DAO::executeQuery("SHOW VARIABLES LIKE 'character_set_database'")->fetchAll();
+    $charSet = $charSetDB[0]['Value'];
+    if ($charSet == 'utf8') {
+      return TRUE;
+    }
+    return FALSE;
+  }
+
 }