Skip to content

Commit

Permalink
Fix wikis being deleted (#155)
Browse files Browse the repository at this point in the history
Bug: T5961
  • Loading branch information
paladox committed Jul 24, 2020
1 parent 49bbb33 commit 92879eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
23 changes: 13 additions & 10 deletions includes/CreateWikiJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ private function generateDatabaseList() {

foreach ( $allWikis as $wiki ) {
if ( $wiki->wiki_deleted == 1 ) {
$deletedList[] = $wiki->wiki_dbname;
}

$combiList[$wiki->wiki_dbname] = [
's' => $wiki->wiki_sitename,
'c' => $wiki->wiki_dbcluster
];

if ( !is_null( $wiki->wiki_url ) ) {
$combiList[$wiki->wiki_dbname]['u'] = $wiki->wiki_url;
$deletedList[$wiki->wiki_dbname] = [
's' => $wiki->wiki_sitename,
'c' => $wiki->wiki_dbcluster
];
} else {
$combiList[$wiki->wiki_dbname] = [
's' => $wiki->wiki_sitename,
'c' => $wiki->wiki_dbcluster
];

if ( !is_null( $wiki->wiki_url ) ) {
$combiList[$wiki->wiki_dbname]['u'] = $wiki->wiki_url;
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion includes/WikiInitialise.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function setVariables( string $cacheDir, array $suffixes, array $siteMatc
if ( PHP_SAPI == 'cli' && file_exists( $this->cacheDir . '/deleted.json' ) ) {
$deletedDatabases = json_decode( file_get_contents( $this->cacheDir . '/deleted.json' ), true );

$this->config->wikis = array_merge( $this->config->wikis, $deletedDatabases['databases'] );
$this->config->wikis = array_merge( $this->config->wikis, array_keys( $deletedDatabases['databases'] ) );

foreach ( $deletedDatabases['databases'] as $db => $data ) {
$this->config->settings['wgSitename'][$db] = $data['s'];
$this->wikiDBClusters[$db] = $data['c'];
}
}

// Now let's formalise our database list to the world
Expand Down

0 comments on commit 92879eb

Please sign in to comment.