Skip to content

Commit

Permalink
Merge pull request civicrm#11249 from seamuslee001/CRM-21363-maria
Browse files Browse the repository at this point in the history
CRM-21363 Only implement ONLY_FULL_GROUP_BY if it is in the default g…
  • Loading branch information
eileenmcnaughton authored and sluc23 committed Jan 10, 2018
2 parents 1a872ed + 15f0111 commit 5c6d5dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function init($dsn) {
CRM_Core_DAO::setFactory($factory);
$currentModes = CRM_Utils_SQL::getSqlModes();
if (CRM_Utils_Constant::value('CIVICRM_MYSQL_STRICT', CRM_Utils_System::isDevelopment())) {
if (CRM_Utils_SQL::supportsFullGroupBy() && !in_array('ONLY_FULL_GROUP_BY', $currentModes)) {
if (CRM_Utils_SQL::supportsFullGroupBy() && !in_array('ONLY_FULL_GROUP_BY', $currentModes) && CRM_Utils_SQL::isGroupByModeInDefault()) {
$currentModes[] = 'ONLY_FULL_GROUP_BY';
}
if (!in_array('STRICT_TRANS_TABLES', $currentModes)) {
Expand Down
15 changes: 15 additions & 0 deletions CRM/Utils/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,19 @@ public static function disableFullGroupByMode() {
return FALSE;
}

/**
* CHeck if ONLY_FULL_GROUP_BY is in the global sql_modes
* @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;
}
return TRUE;
}

}

0 comments on commit 5c6d5dc

Please sign in to comment.