X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FDatabaseUpdater.php;h=1cd76b9565178bf2f9c6210da81ef3439f99045e;hb=138298b397b308ad6e4bfc7088884d90e8ac1e37;hp=ba102782d22abfbf01aa01ac51e0679600047db6;hpb=339adab63a1e6016446743f2003d42fbfc1fbace;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index ba102782d2..1cd76b9565 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -82,7 +82,7 @@ abstract class DatabaseUpdater { PopulateBacklinkNamespace::class, FixDefaultJsonContentPages::class, CleanupEmptyCategories::class, - AddRFCAndPMIDInterwiki::class, + AddRFCandPMIDInterwiki::class, PopulatePPSortKey::class, PopulateIpChanges::class, ]; @@ -410,9 +410,9 @@ abstract class DatabaseUpdater { foreach ( $updates as $funcList ) { $func = $funcList[0]; - $arg = $funcList[1]; + $args = $funcList[1]; $origParams = $funcList[2]; - call_user_func_array( $func, $arg ); + $func( ...$args ); flush(); $this->updatesSkipped[] = $origParams; } @@ -479,7 +479,7 @@ abstract class DatabaseUpdater { } elseif ( $passSelf ) { array_unshift( $params, $this ); } - $ret = call_user_func_array( $func, $params ); + $ret = $func( ...$params ); flush(); if ( $ret !== false ) { $updatesDone[] = $origParams; @@ -779,6 +779,39 @@ abstract class DatabaseUpdater { return true; } + /** + * Add a new index to an existing table if none of the given indexes exist + * + * @param string $table Name of the table to modify + * @param string[] $indexes Name of the indexes to check. $indexes[0] should + * be the one actually being added. + * @param string $patch Path to the patch file + * @param bool $fullpath Whether to treat $patch path as a relative or not + * @return bool False if this was skipped because schema changes are skipped + */ + protected function addIndexIfNoneExist( $table, $indexes, $patch, $fullpath = false ) { + if ( !$this->doTable( $table ) ) { + return true; + } + + if ( !$this->db->tableExists( $table, __METHOD__ ) ) { + $this->output( "...skipping: '$table' table doesn't exist yet.\n" ); + return true; + } + + $newIndex = $indexes[0]; + foreach ( $indexes as $index ) { + if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) { + $this->output( + "...skipping index $newIndex because index $index already set on $table table.\n" + ); + return true; + } + } + + return $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" ); + } + /** * Drop a field from an existing table *