Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
it-spiderman authored and osnard committed Nov 8, 2024
1 parent fa61fac commit 0b85e7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Commands/WikiBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ private function setupFarmEnvironment( array $options ) {
$this->dbprefix = $mainDbPrefix;
$this->mediawikiRoot = $originalMWRoot;
$this->isFarmContext = false;
// Once every instance is backed up, make sure to no export any of those tables when backing up
// the main instances, so get all instance db prefixes, so we can skip them
$this->skipDbPrefixes = $this->farmSettingsReader->getAllInstancePrefixes( $this->dbname );
} else {
$this->mediawikiRoot = "$instancesDir/$this->instanceName";
Expand Down Expand Up @@ -464,6 +466,7 @@ protected function dumpDatabase() {
$dumpSettings['include-tables'] = $this->getTablesWithPrefix( [ $this->dbprefix ] );
}
$dumpSettings['exclude-tables'] = array_merge(
// If multiple instances share a DB, skip all tables with other prefixes
$dumpSettings['exclude-tables'] ?? [],
$this->getTablesWithPrefix( $this->skipDbPrefixes, true )
);
Expand Down Expand Up @@ -509,6 +512,9 @@ protected function addSettingsFiles() {

protected function cleanUp() {
unlink( $this->tmpDumpFilepath );
if ( $this->isFarmContext ) {
unlink( $this->mediawikiRoot . '/settings.json' );
}
}

/**
Expand Down Expand Up @@ -562,7 +568,8 @@ private function removeOldBackups() {

/**
* @param array $prefixes
* @param bool $includeViews
* @param bool $includeViews If we are getting tables to backup, we don't want views, but if we are getting
* tables to skip, we want views
* @return array
*/
private function getTablesWithPrefix( array $prefixes, bool $includeViews = false ): array {
Expand Down

0 comments on commit 0b85e7a

Please sign in to comment.