Skip to content

Commit 21a4113

Browse files
committed
Check if ONLY_FULL_GROUP_BY is disabled
1 parent 369df6a commit 21a4113

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/DBmysql.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ public function connect($choice = null)
266266

267267
$this->dbh->query("SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))");
268268

269+
//check if previous query was successful
270+
$req = $this->doQuery("SELECT @@sql_mode as mode");
271+
if (($data = $req->fetch_array())) {
272+
if (!str_contains(strtoupper($data['mode']), 'ONLY_FULL_GROUP_BY')) {
273+
trigger_error(
274+
'GLPI requires ONLY_FULL_GROUP_BY mode to be disabled; but this cannot be achieved programmatically. Please fix your database configuration.',
275+
E_USER_ERROR
276+
);
277+
}
278+
}
279+
280+
269281
$this->connected = true;
270282

271283
$this->setTimezone($this->guessTimezone());

0 commit comments

Comments
 (0)