X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FDatabaseUpdater.php;h=3412aef2efa5ee5816143c669bd130f773ac36f2;hb=5a451fd01be397db3209c1881a335423706da5c2;hp=8a9cd058716785752042be901af57d12fd26ed83;hpb=72fa557f45ce6640bd13e82c7130ad7934d8c384;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 8a9cd05871..3412aef2ef 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -1233,6 +1233,7 @@ abstract class DatabaseUpdater { $cl = $this->maintenance->runChild( RebuildLocalisationCache::class, 'rebuildLocalisationCache.php' ); + '@phan-var RebuildLocalisationCache $cl'; $this->output( "Rebuilding localisation cache...\n" ); $cl->setForce(); $cl->execute(); @@ -1292,6 +1293,7 @@ abstract class DatabaseUpdater { $task = $this->maintenance->runChild( MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php' ); + // @phan-suppress-next-line PhanUndeclaredMethod $task->setForce(); $ok = $task->execute(); $this->output( $ok ? "done.\n" : "errors were encountered.\n" ); @@ -1306,10 +1308,7 @@ abstract class DatabaseUpdater { * @since 1.31 */ protected function migrateActors() { - global $wgActorTableSchemaMigrationStage; - if ( ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) && - !$this->updateRowExists( 'MigrateActors' ) - ) { + if ( !$this->updateRowExists( 'MigrateActors' ) ) { $this->output( "Migrating actors to the 'actor' table, printing progress markers. For large\n" . "databases, you may want to hit Ctrl-C and do this manually with\n" . @@ -1329,6 +1328,7 @@ abstract class DatabaseUpdater { if ( $this->db->fieldExists( 'archive', 'ar_text', __METHOD__ ) ) { $this->output( "Migrating archive ar_text to modern storage.\n" ); $task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' ); + // @phan-suppress-next-line PhanUndeclaredMethod $task->setForce(); if ( $task->execute() ) { $this->applyPatch( 'patch-drop-ar_text.sql', false, @@ -1398,4 +1398,43 @@ abstract class DatabaseUpdater { } } } + + /** + * Only run a function if the `actor` table does not exist + * + * The transition to the actor table is dropping several indexes (and a few + * fields) that old upgrades want to add. This function is used to prevent + * those from running to re-add things when the `actor` table exists, while + * still allowing them to run if this really is an upgrade from an old MW + * version. + * + * @since 1.34 + * @param string|array|static $func Normally this is the string naming the method on $this to + * call. It may also be an array callable. If passed $this, it's assumed to be a call from + * runUpdates() with $passSelf = true: $params[0] is assumed to be the real $func and $this + * is prepended to the rest of $params. + * @param mixed ...$params Parameters for `$func` + * @return mixed Whatever $func returns, or null when skipped. + */ + protected function ifNoActorTable( $func, ...$params ) { + if ( $this->tableExists( 'actor' ) ) { + return null; + } + + // Handle $passSelf from runUpdates(). + $passSelf = false; + if ( $func === $this ) { + $passSelf = true; + $func = array_shift( $params ); + } + + if ( !is_array( $func ) && method_exists( $this, $func ) ) { + $func = [ $this, $func ]; + } elseif ( $passSelf ) { + array_unshift( $params, $this ); + } + + // @phan-suppress-next-line PhanUndeclaredInvokeInCallable Phan is confused + return $func( ...$params ); + } }