Commit 154bf531 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski
Browse files

Limit sql_mode changes to removal of "ONLY_FULL_GROUP_BY"

parent 04365b2c
......@@ -19,7 +19,7 @@
"DB", "DBSlave",
"// GLPI base constants (they are not detected as they are dynamically declared)",
"GLPI_AJAX_DASHBOARD", "GLPI_CALDAV_IMPORT_STATE", "GLPI_CACHE_DIR", "GLPI_CRON_DIR", "GLPI_CSRF_EXPIRES", "GLPI_CSRF_MAX_TOKENS", "GLPI_USE_IDOR_CHECK", "GLPI_IDOR_EXPIRES", "GLPI_DEMO_MODE", "GLPI_DOC_DIR", "GLPI_DUMP_DIR", "GLPI_FORCE_EMPTY_SQL_MODE", "GLPI_GRAPH_DIR", "GLPI_INSTALL_MODE", "GLPI_LOCAL_I18N_DIR", "GLPI_LOCK_DIR", "GLPI_LOG_DIR", "GLPI_MARKETPLACE_DIR", "GLPI_MARKETPLACE_PLUGINS_API_URI", "GLPI_MARKETPLACE_PRERELEASES", "GLPI_NETWORK_REGISTRATION_API_URL", "GLPI_NETWORK_MAIL", "GLPI_NETWORK_SERVICES", "GLPI_PICTURE_DIR", "GLPI_PLUGIN_DOC_DIR", "GLPI_RSS_DIR", "GLPI_SESSION_DIR", "GLPI_TELEMETRY_URI", "GLPI_TMP_DIR", "GLPI_UPLOAD_DIR", "GLPI_USE_CSRF_CHECK", "GLPI_USER_AGENT_EXTRA_COMMENTS",
"GLPI_AJAX_DASHBOARD", "GLPI_CALDAV_IMPORT_STATE", "GLPI_CACHE_DIR", "GLPI_CRON_DIR", "GLPI_CSRF_EXPIRES", "GLPI_CSRF_MAX_TOKENS", "GLPI_USE_IDOR_CHECK", "GLPI_IDOR_EXPIRES", "GLPI_DEMO_MODE", "GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE", "GLPI_DOC_DIR", "GLPI_DUMP_DIR", "GLPI_FORCE_EMPTY_SQL_MODE", "GLPI_GRAPH_DIR", "GLPI_INSTALL_MODE", "GLPI_LOCAL_I18N_DIR", "GLPI_LOCK_DIR", "GLPI_LOG_DIR", "GLPI_MARKETPLACE_DIR", "GLPI_MARKETPLACE_PLUGINS_API_URI", "GLPI_MARKETPLACE_PRERELEASES", "GLPI_NETWORK_REGISTRATION_API_URL", "GLPI_NETWORK_MAIL", "GLPI_NETWORK_SERVICES", "GLPI_PICTURE_DIR", "GLPI_PLUGIN_DOC_DIR", "GLPI_RSS_DIR", "GLPI_SESSION_DIR", "GLPI_TELEMETRY_URI", "GLPI_TMP_DIR", "GLPI_UPLOAD_DIR", "GLPI_USE_CSRF_CHECK", "GLPI_USER_AGENT_EXTRA_COMMENTS",
"// GLPI optionnal constants",
"GLPI_FORCE_MAIL", "GLPI_LOG_LVL",
......
......@@ -19,6 +19,7 @@ The present file will list all changes made to the project; according to the
#### Changes
#### Deprecated
- Usage of `GLPI_FORCE_EMPTY_SQL_MODE` constant
#### Removed
- `Update::declareOldItems()`
......
......@@ -89,12 +89,13 @@ include_once (GLPI_ROOT . "/inc/autoload.function.php");
'GLPI_MARKETPLACE_PRERELEASES' => false, // display pre-releases of plugins in marketplace
'GLPI_USER_AGENT_EXTRA_COMMENTS' => '', // Extra comment to add to GLPI User-Agent
// SQL compatibility
'GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE' => '1', // '1' to disable ONLY_FULL_GROUP_BY 'sql_mode'
// Other constants
'GLPI_AJAX_DASHBOARD' => '1',
'GLPI_CALDAV_IMPORT_STATE' => 0, // external events created from a caldav client will take this state by default (0 = Planning::INFO)
'GLPI_DEMO_MODE' => '0',
// TODO GLPI_FORCE_EMPTY_SQL_MODE need to be set to 0 after review of all sql queries
'GLPI_FORCE_EMPTY_SQL_MODE' => '1', // for compatibility with mysql 5.7
];
// Define constants values based on server env variables (i.e. defined using apache SetEnv directive)
......
......@@ -214,8 +214,11 @@ class DBmysql {
// force mysqlnd to return int and float types correctly (not as strings)
$this->dbh->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);
if (GLPI_FORCE_EMPTY_SQL_MODE) {
if (defined('GLPI_FORCE_EMPTY_SQL_MODE') && GLPI_FORCE_EMPTY_SQL_MODE) {
Toolbox::deprecated('Usage of GLPI_FORCE_EMPTY_SQL_MODE has been deprecated');
$this->dbh->query("SET SESSION sql_mode = ''");
} else if (GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE) {
$this->dbh->query("SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))");
}
$this->connected = true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment