From 021912da3a5620ac05e8d6c71414fe41d8560478 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 30 Jan 2024 14:26:00 +0100 Subject: [PATCH] Don't guess system schema collation Signed-off-by: Kamil Tekiela --- libraries/classes/DatabaseInterface.php | 6 ------ test/classes/DatabaseInterfaceTest.php | 16 ++++++++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 54d033288a..f1e73ef7e3 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -2210,12 +2210,6 @@ class DatabaseInterface implements DbalInterface */ public function getDbCollation(string $db): string { - if (Utilities::isSystemSchema($db)) { - // We don't have to check the collation of the virtual - // information_schema database: We know it! - return 'utf8_general_ci'; - } - if (! $GLOBALS['cfg']['Server']['DisableIS']) { // this is slow with thousands of databases $sql = 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA' diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php index 3d4c49b73f..f58a3082fa 100644 --- a/test/classes/DatabaseInterfaceTest.php +++ b/test/classes/DatabaseInterfaceTest.php @@ -278,12 +278,6 @@ class DatabaseInterfaceTest extends AbstractTestCase public function testGetDbCollation(): void { $GLOBALS['server'] = 1; - // test case for system schema - $this->assertEquals( - 'utf8_general_ci', - $this->dbi->getDbCollation('information_schema') - ); - $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['cfg']['DBG']['sql'] = false; @@ -291,6 +285,16 @@ class DatabaseInterfaceTest extends AbstractTestCase 'utf8_general_ci', $this->dbi->getDbCollation('pma_test') ); + + $GLOBALS['cfg']['Server']['DisableIS'] = true; + + $this->dummyDbi->addSelectDb('information_schema'); + $GLOBALS['db'] = 'information_schema'; + + $this->dummyDbi->removeDefaultResults(); + $this->dummyDbi->addResult('SELECT @@collation_database', [['utf8mb3_general_ci']], ['@@collation_database']); + + $this->assertEquals('utf8mb3_general_ci', $this->dbi->getDbCollation('information_schema')); } /**