Skip to content

Commit 5c4aa17

Browse files
committed
Don't use double quotes in MySQL queries
MySQL databases with the ANSI_QUOTES mode enabled treat " as an identifier quote (see https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_ansi_quotes). So for such databases the 'occ upgrade' fails with an error message like this: ... unknown column 'oc_*' in where clause. This fix replaces the doulbe quotes with single quotes that should be always used in MySQL queries to quote literal strings. Signed-off-by: Robin Müller <robin.mueller@1und1.de>
1 parent b7ee624 commit 5c4aa17

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/private/Repair/Collation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @author Morris Jobke <hey@morrisjobke.de>
77
* @author Robin Appelman <robin@icewind.nl>
88
* @author Thomas Müller <thomas.mueller@tmit.eu>
9+
* @author Robin Müller <robin.mueller@1und1.de>
910
*
1011
* @license AGPL-3.0
1112
*
@@ -124,7 +125,7 @@ protected function getAllNonUTF8BinTables(IDBConnection $connection) {
124125
" FROM INFORMATION_SCHEMA . COLUMNS" .
125126
" WHERE TABLE_SCHEMA = ?" .
126127
" AND (COLLATION_NAME <> '" . $characterSet . "_bin' OR CHARACTER_SET_NAME <> '" . $characterSet . "')" .
127-
" AND TABLE_NAME LIKE \"*PREFIX*%\"",
128+
" AND TABLE_NAME LIKE '*PREFIX*%'",
128129
array($dbName)
129130
);
130131
$rows = $statement->fetchAll();
@@ -139,7 +140,7 @@ protected function getAllNonUTF8BinTables(IDBConnection $connection) {
139140
" FROM INFORMATION_SCHEMA . TABLES" .
140141
" WHERE TABLE_SCHEMA = ?" .
141142
" AND TABLE_COLLATION <> '" . $characterSet . "_bin'" .
142-
" AND TABLE_NAME LIKE \"*PREFIX*%\"",
143+
" AND TABLE_NAME LIKE '*PREFIX*%'",
143144
[$dbName]
144145
);
145146
$rows = $statement->fetchAll();

tests/lib/Repair/RepairCollationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function setUp() {
7070

7171
$dbPrefix = $this->config->getSystemValue("dbtableprefix");
7272
$this->tableName = $this->getUniqueID($dbPrefix . "_collation_test");
73+
$this->connection->exec("SET SESSION sql_mode = CONCAT(@@SESSION.sql_mode, ',ANSI_QUOTES')");
7374
$this->connection->exec("CREATE TABLE $this->tableName(text VARCHAR(16)) COLLATE utf8_unicode_ci");
7475

7576
$this->repair = new TestCollationRepair($this->config, $this->logger, $this->connection, false);

0 commit comments

Comments
 (0)