From c758df9be6c0b7a3c20a5583174411773fb0ffb9 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 30 Jul 2020 01:17:55 +0100 Subject: [PATCH] Issue #2925318 by phenaproxima, fgm, jungle, Kristen Pol, Berdir: Redundant index sid on locales_translation --- core/modules/locale/locale.install | 12 +++++- .../src/Functional/LocaleUpdatePathTest.php | 38 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 core/modules/locale/tests/src/Functional/LocaleUpdatePathTest.php diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index dfc9fdcbee72..6f33b78f00f8 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -183,7 +183,6 @@ function locale_schema() { ], ], 'indexes' => [ - 'string_id' => ['sid'], 'string_type' => ['sid', 'type'], ], ]; @@ -308,6 +307,17 @@ function locale_requirements($phase) { return $requirements; } +/** + * Delete an unnecessary index on the locales_location table. + */ +function locale_update_9101() { + $schema = \Drupal::database()->schema(); + $table = 'locales_location'; + if ($schema->indexExists($table, 'string_id')) { + $schema->dropIndex($table, 'string_id'); + } +} + /** * Implements hook_update_last_removed(). */ diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdatePathTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdatePathTest.php new file mode 100644 index 000000000000..5cc5fcaa2163 --- /dev/null +++ b/core/modules/locale/tests/src/Functional/LocaleUpdatePathTest.php @@ -0,0 +1,38 @@ +<?php + +namespace Drupal\Tests\locale\Functional; + +use Drupal\Core\Database\Database; +use Drupal\FunctionalTests\Update\UpdatePathTestBase; + +/** + * Tests Locale's update path. + * + * @group locale + */ +class LocaleUpdatePathTest extends UpdatePathTestBase { + + /** + * {@inheritdoc} + */ + protected function setDatabaseDumpFiles() { + $this->databaseDumpFiles = [ + dirname(__DIR__, 4) . '/system/tests/fixtures/update/drupal-8.8.0.filled.standard.php.gz', + ]; + } + + /** + * Tests Locale's update path. + */ + public function testUpdatePath() { + $schema = Database::getConnection()->schema(); + $this->assertTrue($schema->indexExists('locales_location', 'string_id')); + $this->assertTrue($schema->indexExists('locales_location', 'string_type')); + + $this->runUpdates(); + + $this->assertFalse($schema->indexExists('locales_location', 'string_id')); + $this->assertTrue($schema->indexExists('locales_location', 'string_type')); + } + +} -- GitLab