diff --git a/lib/Alchemy/Phrasea/Command/Command.php b/lib/Alchemy/Phrasea/Command/Command.php index 04855c249c..b00362ded9 100644 --- a/lib/Alchemy/Phrasea/Command/Command.php +++ b/lib/Alchemy/Phrasea/Command/Command.php @@ -33,21 +33,17 @@ abstract class Command extends SymfoCommand * Check if Phraseanet is set-up and if the current command requires * Phraseanet to be set-up * - * @param \Symfony\Component\Console\Output\OutputInterface $output + * @throws \RuntimeException * @return Boolean */ - public function checkSetup(OutputInterface $output) + public function checkSetup() { if ($this->requireSetup()) { $core = \bootstrap::getCore(); if ( ! $core->getConfiguration()->isInstalled()) { - $output->writeln("Phraseanet is not set up"); - - return false; + throw new \RuntimeException('Phraseanet must be set-up'); } } - - return true; } } diff --git a/lib/classes/module/console/aboutAuthors.class.php b/lib/classes/module/console/aboutAuthors.class.php index 5f730a94fe..00fb2f38d1 100644 --- a/lib/classes/module/console/aboutAuthors.class.php +++ b/lib/classes/module/console/aboutAuthors.class.php @@ -33,9 +33,7 @@ class module_console_aboutAuthors extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $output->writeln(file_get_contents(__DIR__ . '/../../../../AUTHORS')); diff --git a/lib/classes/module/console/aboutLicense.class.php b/lib/classes/module/console/aboutLicense.class.php index 5dcd6f11b8..9cf4e94114 100644 --- a/lib/classes/module/console/aboutLicense.class.php +++ b/lib/classes/module/console/aboutLicense.class.php @@ -33,9 +33,7 @@ class module_console_aboutLicense extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $output->writeln(file_get_contents(__DIR__ . '/../../../../LICENSE')); diff --git a/lib/classes/module/console/checkExtension.class.php b/lib/classes/module/console/checkExtension.class.php index 10d0926207..9b1cd6ccd0 100644 --- a/lib/classes/module/console/checkExtension.class.php +++ b/lib/classes/module/console/checkExtension.class.php @@ -43,9 +43,7 @@ class module_console_checkExtension extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); if ( ! extension_loaded('phrasea2')) { $output->writeln("Missing Extension php-phrasea."); diff --git a/lib/classes/module/console/fieldsDelete.class.php b/lib/classes/module/console/fieldsDelete.class.php index cb5489d5bc..c64691445f 100644 --- a/lib/classes/module/console/fieldsDelete.class.php +++ b/lib/classes/module/console/fieldsDelete.class.php @@ -42,9 +42,7 @@ class module_console_fieldsDelete extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); try { $databox = \databox::get_instance((int) $input->getArgument('sbas_id')); diff --git a/lib/classes/module/console/fieldsList.class.php b/lib/classes/module/console/fieldsList.class.php index 95f5dfe109..26d8128f62 100644 --- a/lib/classes/module/console/fieldsList.class.php +++ b/lib/classes/module/console/fieldsList.class.php @@ -38,9 +38,7 @@ class module_console_fieldsList extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $appbox = \appbox::get_instance(\bootstrap::getCore()); diff --git a/lib/classes/module/console/fieldsMerge.class.php b/lib/classes/module/console/fieldsMerge.class.php index 71bcffaeed..83330fec05 100644 --- a/lib/classes/module/console/fieldsMerge.class.php +++ b/lib/classes/module/console/fieldsMerge.class.php @@ -52,9 +52,7 @@ class module_console_fieldsMerge extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $output->writeln(""); diff --git a/lib/classes/module/console/fieldsRename.class.php b/lib/classes/module/console/fieldsRename.class.php index 5decdd85de..49c5f8232a 100644 --- a/lib/classes/module/console/fieldsRename.class.php +++ b/lib/classes/module/console/fieldsRename.class.php @@ -43,9 +43,7 @@ class module_console_fieldsRename extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $new_name = $input->getArgument('name'); diff --git a/lib/classes/module/console/fileEnsureDevSetting.class.php b/lib/classes/module/console/fileEnsureDevSetting.class.php index 5f48cbdf75..5c46598bd3 100644 --- a/lib/classes/module/console/fileEnsureDevSetting.class.php +++ b/lib/classes/module/console/fileEnsureDevSetting.class.php @@ -62,9 +62,7 @@ class module_console_fileEnsureDevSetting extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification(); diff --git a/lib/classes/module/console/fileEnsureProductionSetting.class.php b/lib/classes/module/console/fileEnsureProductionSetting.class.php index 6f29c3e6db..fe760344ad 100644 --- a/lib/classes/module/console/fileEnsureProductionSetting.class.php +++ b/lib/classes/module/console/fileEnsureProductionSetting.class.php @@ -62,9 +62,7 @@ class module_console_fileEnsureProductionSetting extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification(); diff --git a/lib/classes/module/console/schedulerStart.class.php b/lib/classes/module/console/schedulerStart.class.php index bc02bcad5e..03b6e45c8f 100644 --- a/lib/classes/module/console/schedulerStart.class.php +++ b/lib/classes/module/console/schedulerStart.class.php @@ -41,9 +41,7 @@ class module_console_schedulerStart extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - return 1; - } + $this->checkSetup(); $logger = new Logger('Task logger'); diff --git a/lib/classes/module/console/schedulerState.class.php b/lib/classes/module/console/schedulerState.class.php index fb898f3251..d015552ba3 100644 --- a/lib/classes/module/console/schedulerState.class.php +++ b/lib/classes/module/console/schedulerState.class.php @@ -56,8 +56,9 @@ class module_console_schedulerState extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - + try{ + $this->checkSetup(); + } catch (\RuntimeException $e){ return self::EXITCODE_SETUP_ERROR; } diff --git a/lib/classes/module/console/schedulerStop.class.php b/lib/classes/module/console/schedulerStop.class.php index 8d2f3655d5..25708107c8 100644 --- a/lib/classes/module/console/schedulerStop.class.php +++ b/lib/classes/module/console/schedulerStop.class.php @@ -38,10 +38,7 @@ class module_console_schedulerStop extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); require_once __DIR__ . '/../../../../lib/bootstrap.php'; diff --git a/lib/classes/module/console/sphinxGenerateSuggestion.class.php b/lib/classes/module/console/sphinxGenerateSuggestion.class.php index 925349e6e0..09bb8f7c4d 100644 --- a/lib/classes/module/console/sphinxGenerateSuggestion.class.php +++ b/lib/classes/module/console/sphinxGenerateSuggestion.class.php @@ -39,10 +39,7 @@ class module_console_sphinxGenerateSuggestion extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); define('FREQ_THRESHOLD', 10); define('SUGGEST_DEBUG', 0); diff --git a/lib/classes/module/console/systemBackupDB.class.php b/lib/classes/module/console/systemBackupDB.class.php index a1aac0e640..9042e75fa3 100644 --- a/lib/classes/module/console/systemBackupDB.class.php +++ b/lib/classes/module/console/systemBackupDB.class.php @@ -45,10 +45,7 @@ class module_console_systemBackupDB extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $output->write('Phraseanet is going to be backup...', true); diff --git a/lib/classes/module/console/systemClearCache.class.php b/lib/classes/module/console/systemClearCache.class.php index ac84e08e4c..f5c4e2a4e8 100644 --- a/lib/classes/module/console/systemClearCache.class.php +++ b/lib/classes/module/console/systemClearCache.class.php @@ -39,10 +39,7 @@ class module_console_systemClearCache extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $finder = new Finder(); diff --git a/lib/classes/module/console/systemConfigCheck.class.php b/lib/classes/module/console/systemConfigCheck.class.php index f96f6ac5e5..18203b8347 100644 --- a/lib/classes/module/console/systemConfigCheck.class.php +++ b/lib/classes/module/console/systemConfigCheck.class.php @@ -39,10 +39,7 @@ class module_console_systemConfigCheck extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); if ( ! function_exists('_')) { $output->writeln('YOU MUST ENABLE GETTEXT SUPPORT TO USE PHRASEANET'); diff --git a/lib/classes/module/console/systemExport.class.php b/lib/classes/module/console/systemExport.class.php index b9cb3a7907..751d36d8c5 100644 --- a/lib/classes/module/console/systemExport.class.php +++ b/lib/classes/module/console/systemExport.class.php @@ -78,10 +78,7 @@ class module_console_systemExport extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $core = \bootstrap::getCore(); diff --git a/lib/classes/module/console/systemMailCheck.class.php b/lib/classes/module/console/systemMailCheck.class.php index 68a0e79504..60dfd8034b 100644 --- a/lib/classes/module/console/systemMailCheck.class.php +++ b/lib/classes/module/console/systemMailCheck.class.php @@ -44,10 +44,7 @@ class module_console_systemMailCheck extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $appbox = appbox::get_instance(\bootstrap::getCore()); diff --git a/lib/classes/module/console/systemTemplateGenerator.class.php b/lib/classes/module/console/systemTemplateGenerator.class.php index 056c1b9876..ca43a1f982 100644 --- a/lib/classes/module/console/systemTemplateGenerator.class.php +++ b/lib/classes/module/console/systemTemplateGenerator.class.php @@ -38,10 +38,7 @@ class module_console_systemTemplateGenerator extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $tplDirs = array( realpath(__DIR__ . '/../../../../templates/web/'), diff --git a/lib/classes/module/console/systemUpgrade.class.php b/lib/classes/module/console/systemUpgrade.class.php index 5804d515d2..f6c7791217 100644 --- a/lib/classes/module/console/systemUpgrade.class.php +++ b/lib/classes/module/console/systemUpgrade.class.php @@ -39,10 +39,7 @@ class module_console_systemUpgrade extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - - return 1; - } + $this->checkSetup(); $Core = \bootstrap::getCore(); diff --git a/lib/classes/module/console/taskState.class.php b/lib/classes/module/console/taskState.class.php index 3b65d68473..785acedae8 100644 --- a/lib/classes/module/console/taskState.class.php +++ b/lib/classes/module/console/taskState.class.php @@ -64,8 +64,9 @@ class module_console_taskState extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - + try{ + $this->checkSetup(); + } catch (\RuntimeException $e){ return self::EXITCODE_SETUP_ERROR; } diff --git a/lib/classes/module/console/tasklist.class.php b/lib/classes/module/console/tasklist.class.php index 9be3ba0761..549c100cae 100644 --- a/lib/classes/module/console/tasklist.class.php +++ b/lib/classes/module/console/tasklist.class.php @@ -39,8 +39,9 @@ class module_console_tasklist extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - + try{ + $this->checkSetup(); + } catch (\RuntimeException $e){ return self::EXITCODE_SETUP_ERROR; } diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php index dccff2f907..61a48391f1 100644 --- a/lib/classes/module/console/taskrun.class.php +++ b/lib/classes/module/console/taskrun.class.php @@ -72,8 +72,9 @@ class module_console_taskrun extends Command public function execute(InputInterface $input, OutputInterface $output) { - if ( ! $this->checkSetup($output)) { - + try{ + $this->checkSetup(); + } catch (\RuntimeException $e){ return self::EXITCODE_SETUP_ERROR; }