From 9b065dcf1d4f320ea28b5e08f36bab4f1114b678 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 2 Sep 2017 08:56:57 +1000 Subject: [PATCH] NFC Test using ONLY_FULL_GROUP_BY sqlmode as well --- CRM/Core/DAO.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index c6d3156b80..60ab91ab64 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -119,7 +119,12 @@ class CRM_Core_DAO extends DB_DataObject { $factory = new CRM_Contact_DAO_Factory(); CRM_Core_DAO::setFactory($factory); if (CRM_Utils_Constant::value('CIVICRM_MYSQL_STRICT', CRM_Utils_System::isDevelopment())) { - CRM_Core_DAO::executeQuery('SET SESSION sql_mode = STRICT_TRANS_TABLES'); + if (self::supportsFullGroupBy()) { + CRM_Core_DAO::executeQuery("SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES'"); + } + else { + CRM_Core_DAO::executeQuery("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); + } } CRM_Core_DAO::executeQuery('SET NAMES utf8'); CRM_Core_DAO::executeQuery('SET @uniqueID = %1', array(1 => array(CRM_Utils_Request::id(), 'String'))); @@ -402,6 +407,14 @@ class CRM_Core_DAO extends DB_DataObject { } } + /** + * Does this System support the MYSQL mode ONLY_FULL_GROUP_BY + * @return mixed + */ + public static function supportsFullGroupBy() { + return version_compare(CRM_Core_DAO::singleValueQuery('SELECT VERSION()'), '5.7.0', '>='); + } + /** * Defines the default key as 'id'. * -- 2.25.1