aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerk-Jan Hartman <hartman.wiki@gmail.com>2024-11-13 22:48:16 +0100
committerDerk-Jan Hartman <hartman.wiki@gmail.com>2024-11-14 23:54:00 +0100
commitdef5b99737a296c108310881debe6ecb8bac1b2f (patch)
tree4c05fe73078a179cacd9698cf12717c8aa5ba21b
parent57fe0704496fc788f75f0ed9ee6203eda4c8e3f6 (diff)
downloadmediawikicore-def5b99737a296c108310881debe6ecb8bac1b2f.tar.gz
mediawikicore-def5b99737a296c108310881debe6ecb8bac1b2f.zip
Add migrateSearchindex functions
This runs migrations that were previously attempted. Postgres never executed as the renameindex failed and it never ran the patch either. MySql did run, but was relying on renameIndex with PRIMARY, which is a bad idea. The function now runs it as a patch, with upgrade row in the log, but also checks for the lack of the old index in case the users were already on 1.44 or if they used 1.43rc Bug: T379591 Change-Id: I7e74ccbf8cf2b105e8e6dedf812af3487c18113b
-rw-r--r--includes/installer/MysqlUpdater.php23
-rw-r--r--includes/installer/PostgresUpdater.php30
2 files changed, 51 insertions, 2 deletions
diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php
index 51d051d33586..ae632cda3eae 100644
--- a/includes/installer/MysqlUpdater.php
+++ b/includes/installer/MysqlUpdater.php
@@ -173,7 +173,7 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'modifyField', 'page', 'page_links_updated', 'patch-page-page_links_updated-noinfinite.sql' ],
[ 'addPostDatabaseUpdateMaintenance', FixAutoblockLogTitles::class ],
[ 'changeTableOption', 'searchindex', 'CONVERT TO CHARACTER SET utf8mb4', 'utf8mb4' ],
- [ 'renameIndex', 'searchindex', 'si_page', 'PRIMARY', false, 'patch-searchindex-pk-titlelength.sql' ],
+ [ 'migrateSearchindex' ],
// 1.44
];
@@ -276,6 +276,27 @@ class MysqlUpdater extends DatabaseUpdater {
}
}
+ protected function migrateSearchindex() {
+ $updateKey = 'searchindex-pk-titlelength';
+ if ( !$this->tableExists( 'searchindex' ) ) {
+ return;
+ }
+
+ $primaryIndexExists = $this->db->indexExists( 'searchindex', 'PRIMARY' );
+ if ( $this->updateRowExists( $updateKey ) || $primaryIndexExists ) {
+ $this->output( "...searchindex table has already been migrated.\n" );
+ if ( !$this->updateRowExists( $updateKey ) ) {
+ $this->insertUpdateRow( $updateKey );
+ }
+ return;
+ }
+
+ $apply = $this->applyPatch( 'patch-searchindex-pk-titlelength.sql', false, '...migrating searchindex table' );
+
+ if ( $apply ) {
+ $this->insertUpdateRow( $updateKey );
+ }
+ }
}
/** @deprecated class alias since 1.42 */
diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php
index c737d3c7ead1..918cfd0e6112 100644
--- a/includes/installer/PostgresUpdater.php
+++ b/includes/installer/PostgresUpdater.php
@@ -441,7 +441,7 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'dropTable', 'ipblocks' ],
[ 'dropField', 'pagelinks', 'pl_title', 'patch-pagelinks-drop-pl_title.sql' ],
[ 'addPostDatabaseUpdateMaintenance', FixAutoblockLogTitles::class ],
- [ 'renameIndex', 'searchindex', 'si_page', 'PRIMARY', false, 'patch-searchindex-pk-titlelength.sql' ],
+ [ 'migrateSearchindex' ],
// 1.44
];
@@ -971,4 +971,32 @@ END;
return false;
}
+
+ /**
+ * Replaces unique index with primary key,modifies si_title length
+ *
+ * @since 1.43
+ * @return void
+ */
+ protected function migrateSearchindex() {
+ $updateKey = 'searchindex-pk-titlelength';
+ if ( !$this->tableExists( 'searchindex' ) ) {
+ return;
+ }
+
+ $primaryIndexExists = $this->db->indexExists( 'searchindex', 'searchindex_pkey' );
+ if ( $this->updateRowExists( $updateKey ) || ( $primaryIndexExists ) ) {
+ $this->output( "...searchindex table has already been migrated.\n" );
+ if ( !$this->updateRowExists( $updateKey ) ) {
+ $this->insertUpdateRow( $updateKey );
+ }
+ return;
+ }
+
+ $apply = $this->applyPatch( 'patch-searchindex-pk-titlelength.sql', false, '...migrating searchindex table' );
+
+ if ( $apply ) {
+ $this->insertUpdateRow( $updateKey );
+ }
+ }
}