[ticket/16955] Use constants for exit codes in installer console commands

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-30 17:28:17 +01:00
parent fab81eca2b
commit 3b8f6ae4e9
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
6 changed files with 34 additions and 28 deletions

View file

@ -18,6 +18,7 @@ use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -90,7 +91,7 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
return Command::FAILURE;
}
try
@ -101,7 +102,7 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -115,11 +116,11 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false));
return 0;
return Command::SUCCESS;
}
}

View file

@ -18,6 +18,7 @@ use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -90,7 +91,7 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
return 1;
return Command::FAILURE;
}
try
@ -101,7 +102,7 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -115,10 +116,10 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$iohandler->add_success_message('CONFIGURATION_VALID');
return 0;
return Command::SUCCESS;
}
}

View file

@ -22,6 +22,7 @@ use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -111,14 +112,14 @@ class install extends \phpbb\console\command\command
{
$iohandler->add_error_message('INSTALL_PHPBB_INSTALLED');
return 1;
return Command::FAILURE;
}
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
return Command::FAILURE;
}
try
@ -129,7 +130,7 @@ class install extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -143,7 +144,7 @@ class install extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$this->register_configuration($iohandler, $config);
@ -151,12 +152,12 @@ class install extends \phpbb\console\command\command
try
{
$this->installer->run();
return 0;
return Command::SUCCESS;
}
catch (installer_exception $e)
{
$iohandler->add_error_message($e->getMessage());
return 1;
return Command::FAILURE;
}
}

View file

@ -18,6 +18,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -90,7 +91,7 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
return Command::FAILURE;
}
try
@ -101,7 +102,7 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -115,11 +116,11 @@ class show extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false));
return 0;
return Command::SUCCESS;
}
}

View file

@ -18,6 +18,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -90,7 +91,7 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
return 1;
return Command::FAILURE;
}
try
@ -101,7 +102,7 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -115,10 +116,10 @@ class validate extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$iohandler->add_success_message('CONFIGURATION_VALID');
return 0;
return Command::SUCCESS;
}
}

View file

@ -22,6 +22,7 @@ use phpbb\install\updater_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -111,14 +112,14 @@ class update extends \phpbb\console\command\command
{
$iohandler->add_error_message('INSTALL_PHPBB_NOT_INSTALLED');
return 1;
return Command::FAILURE;
}
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
return Command::FAILURE;
}
try
@ -129,7 +130,7 @@ class update extends \phpbb\console\command\command
{
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
return 1;
return Command::FAILURE;
}
$processor = new Processor();
@ -143,7 +144,7 @@ class update extends \phpbb\console\command\command
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
return Command::FAILURE;
}
$this->register_configuration($iohandler, $config);
@ -151,12 +152,12 @@ class update extends \phpbb\console\command\command
try
{
$this->installer->run();
return 0;
return Command::SUCCESS;
}
catch (installer_exception $e)
{
$iohandler->add_error_message($e->getMessage());
return 1;
return Command::FAILURE;
}
}