From b0df9abec09e3935b04e5c306fce66c34bdc7dde Mon Sep 17 00:00:00 2001 From: "d.savuljesku" Date: Wed, 30 Oct 2024 10:46:33 +0100 Subject: [PATCH] Make farm settings more specific --- README.md | 10 +++++----- ...er.php => BlueSpiceFarmInstanceSettingsManager.php} | 4 +--- src/Commands/WikiBackup.php | 8 ++++---- src/Commands/WikiRestore.php | 8 ++++---- src/DefaultBackupProfile.php | 4 ++-- src/IBackupProfile.php | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) rename src/{FarmInstanceSettingsManager.php => BlueSpiceFarmInstanceSettingsManager.php} (97%) diff --git a/README.md b/README.md index 2b1e82f..004b50a 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,11 @@ main (`w`) wiki database, as that DB holds information on all instances. Commands are the same as for single wiki, but additional parameters in `profile.json` are required - Set all parameters as if backing up/restoring the main farm wiki (`w`, management instance) -- Add section `farm-options` that has following items +- Add section `bluespice-farm-options` that has following items ``` { - "farm-options": { + "bluespice-farm-options": { "instances-dir": "/var/www/w/_sf_instance", "instance-name": "wiki-name" } @@ -130,7 +130,7 @@ with `profile.json`: "dbname": "w" } }, - "farm-options": { + "bluespice-farm-options": { "instance-name": "*" } } @@ -146,7 +146,7 @@ Since instance settings are stored in DB, when backing up, extra file `filesyste which is then used on restore. When restoring a farm instance, profile file __must__ be used, with `db-options.connection` set -to the main wiki database. Optionally, set `farm-options.instances-dir` to the root directory that holds instances. +to the main wiki database. Optionally, set `bluespice-farm-options.instances-dir` to the root directory that holds instances. ```json { @@ -158,7 +158,7 @@ to the main wiki database. Optionally, set `farm-options.instances-dir` to the r "dbname": "w" } }, - "farm-options": { + "bluespice-farm-options": { "instances-dir": "/path/to/instances" } } diff --git a/src/FarmInstanceSettingsManager.php b/src/BlueSpiceFarmInstanceSettingsManager.php similarity index 97% rename from src/FarmInstanceSettingsManager.php rename to src/BlueSpiceFarmInstanceSettingsManager.php index a004a24..10783d7 100644 --- a/src/FarmInstanceSettingsManager.php +++ b/src/BlueSpiceFarmInstanceSettingsManager.php @@ -3,10 +3,8 @@ namespace MWStake\MediaWiki\CliAdm; use PDO; -use RecursiveIteratorIterator; -use MWStake\MediaWiki\CliAdm\SettingsFileIterator; -class FarmInstanceSettingsManager { +class BlueSpiceFarmInstanceSettingsManager { /** * @var PDO diff --git a/src/Commands/WikiBackup.php b/src/Commands/WikiBackup.php index 13ffdb1..e2ff5be 100644 --- a/src/Commands/WikiBackup.php +++ b/src/Commands/WikiBackup.php @@ -4,7 +4,7 @@ use DateTime; use Exception; -use MWStake\MediaWiki\CliAdm\FarmInstanceSettingsManager; +use MWStake\MediaWiki\CliAdm\BlueSpiceFarmInstanceSettingsManager; use MWStake\MediaWiki\CliAdm\IBackupProfile; use MWStake\MediaWiki\CliAdm\JSONBackupProfile; use MWStake\MediaWiki\CliAdm\DefaultBackupProfile; @@ -82,7 +82,7 @@ class WikiBackup extends Command { /** @var array */ private $skipDbPrefixes = []; - /** @var FarmInstanceSettingsManager|null */ + /** @var BlueSpiceFarmInstanceSettingsManager|null */ private $farmSettingsReader = null; /** @@ -205,7 +205,7 @@ protected function readInSettingsFile() { } $this->{$requiredField} = $settings[$requiredField]; } - $farmOptions = $this->profile->getFarmOptions(); + $farmOptions = $this->profile->getBlueSpiceFarmOptions(); if ( $farmOptions && $farmOptions['instance-name'] ) { $this->setupFarmEnvironment( $farmOptions ); } @@ -232,7 +232,7 @@ private function setupFarmEnvironment( array $options ) { throw new Exception( "Could not connect to management database: " . $ex->getMessage() ); } - $this->farmSettingsReader = new FarmInstanceSettingsManager( $mainPdo, $settingsTable ); + $this->farmSettingsReader = new BlueSpiceFarmInstanceSettingsManager( $mainPdo, $settingsTable ); if ( $this->instanceName === '*' ) { $this->output->writeln( "Backing up all instances ..." ); // Backup all instances diff --git a/src/Commands/WikiRestore.php b/src/Commands/WikiRestore.php index fa52d87..e50f668 100644 --- a/src/Commands/WikiRestore.php +++ b/src/Commands/WikiRestore.php @@ -3,7 +3,7 @@ namespace MWStake\MediaWiki\CliAdm\Commands; use DateTime; -use MWStake\MediaWiki\CliAdm\FarmInstanceSettingsManager; +use MWStake\MediaWiki\CliAdm\BlueSpiceFarmInstanceSettingsManager; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; use Symfony\Component\Console\Command\Command; @@ -88,7 +88,7 @@ class WikiRestore extends Command { /** * - * @var FarmInstanceSettingsManager + * @var BlueSpiceFarmInstanceSettingsManager */ private $farmSettingsManager = null; @@ -302,12 +302,12 @@ private function setupFarmEnvironment() { $mainDbConnectionOptions['dbpassword'] ); $settingsTable = ( $mainDbConnectionOptions['dbprefix' ] ?? '' ) . 'simple_farmer_instances'; - $this->farmSettingsManager = new FarmInstanceSettingsManager( $mainPdo, $settingsTable ); + $this->farmSettingsManager = new BlueSpiceFarmInstanceSettingsManager( $mainPdo, $settingsTable ); $settings = $this->farmSettingsManager->getSettingsFromFile( $instanceSettingsFile ); if ( !$settings ) { throw new Exception( "Failed to read settings.json for farm instance" ); } - $farmOptions = $this->profile->getOptions()['farm-options'] ?? null; + $farmOptions = $this->profile->getOptions()['bluespice-farm-options'] ?? null; $instancesDir = $farmOptions['instances-dir'] ?? $this->mediawikiRoot . '/_sf_instances'; $this->instanceName = $settings['path']; $this->settings['dbname'] = $settings['dbname']; diff --git a/src/DefaultBackupProfile.php b/src/DefaultBackupProfile.php index fa62002..9831ed0 100644 --- a/src/DefaultBackupProfile.php +++ b/src/DefaultBackupProfile.php @@ -46,8 +46,8 @@ public function getDBBackupOptions() { /** * @inheritDoc */ - public function getFarmOptions(): ?array { - return $this->getOption( 'farm-options' ); + public function getBlueSpiceFarmOptions(): ?array { + return $this->getOption( 'bluespice-farm-options' ); } /** diff --git a/src/IBackupProfile.php b/src/IBackupProfile.php index 8e8c429..ec0a271 100644 --- a/src/IBackupProfile.php +++ b/src/IBackupProfile.php @@ -24,7 +24,7 @@ public function getDBBackupOptions(); /** * @return array|null */ - public function getFarmOptions(): ?array; + public function getBlueSpiceFarmOptions(): ?array; /** * Key "db-options" should contain DB backup options.