Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions includes/CreateWikiJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use BagOStuff;
use Config;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use Miraheze\CreateWiki\Hooks\CreateWikiHookRunner;
use ObjectCache;
Expand Down Expand Up @@ -268,11 +269,24 @@ private function generateDatabasesJsonFile( array $databaseLists ) {
if ( $tmpFile ) {
if ( file_put_contents( $tmpFile, json_encode( $contents ) ) ) {
if ( !rename( $tmpFile, "{$this->cacheDir}/{$name}.json" ) ) {
unlink( $tmpFile );
LoggerFactory::getInstance( 'CreateWiki' )->error(
'Database cache failure: failure to rename {name} to {newName} on disk.',
[
'name' => $tmpFile,
'newName' => "{$this->cacheDir}/{$name}.json"
]
);
}
} else {
unlink( $tmpFile );
LoggerFactory::getInstance( 'CreateWiki' )->error(
'Database cache failure: failure to write cache to disk at {name}.',
[
'name' => "{$this->cacheDir}/{$name}.json"
]
);
}

unlink( $tmpFile );
}
}
}
Expand Down Expand Up @@ -344,11 +358,24 @@ private function generateWiki() {
if ( $tmpFile ) {
if ( file_put_contents( $tmpFile, json_encode( $jsonArray ) ) ) {
if ( !rename( $tmpFile, "{$this->cacheDir}/{$this->wiki}.json" ) ) {
unlink( $tmpFile );
LoggerFactory::getInstance( 'CreateWiki' )->error(
'Wiki cache failure: failure to rename {name} to {newName} on disk.',
[
'name' => $tmpFile,
'newName' => "{$this->cacheDir}/{$this->wiki}.json"
]
);
}
} else {
unlink( $tmpFile );
LoggerFactory::getInstance( 'CreateWiki' )->error(
'Database cache failure: failure to write cache to disk at {name}.',
[
'name' => "{$this->cacheDir}/{$this->wiki}.json"
]
);
}

unlink( $tmpFile );
}
}

Expand Down