1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-29 02:29:21 +02:00

Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2016-02-29 21:45:16 +01:00
commit b324cf1907
12 changed files with 510 additions and 25 deletions

View File

@ -21,7 +21,6 @@ services:
arguments:
- '@language'
- '@installer.helper.iohandler_factory'
- '@installer.installer.install'
tags:
- { name: console.installer.command }
@ -31,6 +30,32 @@ services:
arguments:
- '@language'
- '@installer.helper.iohandler_factory'
- '@installer.installer.install'
tags:
- { name: console.installer.command }
console.updater.command.update:
class: phpbb\install\console\command\update\update
arguments:
- '@language'
- '@installer.helper.iohandler_factory'
- '@installer.installer.update'
- '@installer.helper.install_helper'
tags:
- { name: console.installer.command }
console.updater.command.config.show:
class: phpbb\install\console\command\update\config\show
arguments:
- '@language'
- '@installer.helper.iohandler_factory'
tags:
- { name: console.installer.command }
console.updater.command.config.validate:
class: phpbb\install\console\command\update\config\validate
arguments:
- '@language'
- '@installer.helper.iohandler_factory'
tags:
- { name: console.installer.command }

View File

@ -0,0 +1,2 @@
updater:
type: all

View File

@ -121,8 +121,6 @@ $lang = array_merge($lang, array(
$lang = array_merge($lang, array(
'INST_ERR_MISSING_DATA' => 'You must fill out all fields in this block.',
'PHPBB_ALREADY_INSTALLED' => 'phpBB is already installed.',
'TIMEOUT_DETECTED_TITLE' => 'The installer detected a timeout',
'TIMEOUT_DETECTED_MESSAGE' => 'The installer has detected a timeout, you may try to refresh the page, which may lead to data corruption. We suggest that you either increase your timeout settings or try to use the CLI.',
));
@ -319,12 +317,14 @@ $lang = array_merge($lang, array(
// CLI messages
$lang = array_merge($lang, array(
'CLI_INSTALL_BOARD' => 'Install phpBB',
'CLI_UPDATE_BOARD' => 'Update phpBB',
'CLI_INSTALL_SHOW_CONFIG' => 'Show the configuration which will be used',
'CLI_INSTALL_VALIDATE_CONFIG' => 'Validate a configuration file',
'CLI_CONFIG_FILE' => 'Config file to use',
'MISSING_FILE' => 'Unable to access file %1$s',
'MISSING_DATA' => 'Config file is missing data or might contain invalid settings.',
'INVALID_YAML_FILE' => 'Could not parse YAML file %1$s',
'CONFIGURATION_VALID' => 'The configuration file is valid',
));
// Common updater messages

View File

@ -14,7 +14,6 @@
namespace phpbb\install\console\command\install\config;
use phpbb\install\helper\iohandler\factory;
use phpbb\install\installer;
use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
@ -33,11 +32,6 @@ class show extends \phpbb\console\command\command
*/
protected $iohandler_factory;
/**
* @var installer
*/
protected $installer;
/**
* @var language
*/
@ -48,12 +42,10 @@ class show extends \phpbb\console\command\command
*
* @param language $language
* @param factory $factory
* @param installer $installer
*/
public function __construct(language $language, factory $factory, installer $installer)
public function __construct(language $language, factory $factory)
{
$this->iohandler_factory = $factory;
$this->installer = $installer;
$this->language = $language;
parent::__construct(new \phpbb\user($language, 'datetime'));
@ -126,6 +118,6 @@ class show extends \phpbb\console\command\command
return;
}
$iohandler->add_log_message(Yaml::dump(array('installer' => $config), 10, 4, true, false));
$style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false));
}
}

View File

@ -14,7 +14,6 @@
namespace phpbb\install\console\command\install\config;
use phpbb\install\helper\iohandler\factory;
use phpbb\install\installer;
use phpbb\install\installer_configuration;
use phpbb\language\language;
use Symfony\Component\Config\Definition\Exception\Exception;
@ -33,11 +32,6 @@ class validate extends \phpbb\console\command\command
*/
protected $iohandler_factory;
/**
* @var installer
*/
protected $installer;
/**
* @var language
*/
@ -48,12 +42,10 @@ class validate extends \phpbb\console\command\command
*
* @param language $language
* @param factory $factory
* @param installer $installer
*/
public function __construct(language $language, factory $factory, installer $installer)
public function __construct(language $language, factory $factory)
{
$this->iohandler_factory = $factory;
$this->installer = $installer;
$this->language = $language;
parent::__construct(new \phpbb\user($language, 'datetime'));

View File

@ -109,7 +109,7 @@ class install extends \phpbb\console\command\command
if ($this->install_helper->is_phpbb_installed())
{
$iohandler->add_error_message('PHPBB_ALREADY_INSTALLED');
$iohandler->add_error_message('INSTALL_PHPBB_INSTALLED');
return 1;
}

View File

@ -0,0 +1,123 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\install\console\command\update\config;
use phpbb\install\helper\iohandler\factory;
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\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
class show extends \phpbb\console\command\command
{
/**
* @var factory
*/
protected $iohandler_factory;
/**
* @var language
*/
protected $language;
/**
* Constructor
*
* @param language $language
* @param factory $factory
*/
public function __construct(language $language, factory $factory)
{
$this->iohandler_factory = $factory;
$this->language = $language;
parent::__construct(new \phpbb\user($language, 'datetime'));
}
/**
*
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update:config:show')
->addArgument(
'config-file',
InputArgument::REQUIRED,
$this->language->lang('CLI_CONFIG_FILE'))
->setDescription($this->language->lang('CLI_INSTALL_SHOW_CONFIG'))
;
}
/**
* Show the validated configuration
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->iohandler_factory->set_environment('cli');
/** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
$iohandler = $this->iohandler_factory->get();
$style = new SymfonyStyle($input, $output);
$iohandler->set_style($style, $output);
$config_file = $input->getArgument('config-file');
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return;
}
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return;
}
$processor = new Processor();
$configuration = new updater_configuration();
try
{
$config = $processor->processConfiguration($configuration, $config);
}
catch (Exception $e)
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return;
}
$style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false));
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\install\console\command\update\config;
use phpbb\install\helper\iohandler\factory;
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\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
class validate extends \phpbb\console\command\command
{
/**
* @var factory
*/
protected $iohandler_factory;
/**
* @var language
*/
protected $language;
/**
* Constructor
*
* @param language $language
* @param factory $factory
*/
public function __construct(language $language, factory $factory)
{
$this->iohandler_factory = $factory;
$this->language = $language;
parent::__construct(new \phpbb\user($language, 'datetime'));
}
/**
*
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update:config:validate')
->addArgument(
'config-file',
InputArgument::REQUIRED,
$this->language->lang('CLI_CONFIG_FILE'))
->setDescription($this->language->lang('CLI_INSTALL_VALIDATE_CONFIG'))
;
}
/**
* Validate the configuration file
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->iohandler_factory->set_environment('cli');
/** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
$iohandler = $this->iohandler_factory->get();
$style = new SymfonyStyle($input, $output);
$iohandler->set_style($style, $output);
$config_file = $input->getArgument('config-file');
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
return 1;
}
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
}
catch (ParseException $e)
{
$iohandler->add_error_message('INVALID_YAML_FILE');
return 1;
}
$processor = new Processor();
$configuration = new updater_configuration();
try
{
$processor->processConfiguration($configuration, $config);
}
catch (Exception $e)
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
}
$iohandler->add_success_message('CONFIGURATION_VALID');
return 0;
}
}

View File

@ -0,0 +1,179 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\install\console\command\update;
use phpbb\install\exception\installer_exception;
use phpbb\install\helper\install_helper;
use phpbb\install\helper\iohandler\cli_iohandler;
use phpbb\install\helper\iohandler\factory;
use phpbb\install\installer;
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\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
class update extends \phpbb\console\command\command
{
/**
* @var factory
*/
protected $iohandler_factory;
/**
* @var installer
*/
protected $installer;
/**
* @var install_helper
*/
protected $install_helper;
/**
* @var language
*/
protected $language;
/**
* Constructor
*
* @param language $language
* @param factory $factory
* @param installer $installer
* @param install_helper $install_helper
*/
public function __construct(language $language, factory $factory, installer $installer, install_helper $install_helper)
{
$this->iohandler_factory = $factory;
$this->installer = $installer;
$this->language = $language;
$this->install_helper = $install_helper;
parent::__construct(new \phpbb\user($language, 'datetime'));
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update')
->addArgument(
'config-file',
InputArgument::REQUIRED,
$this->language->lang('CLI_CONFIG_FILE'))
->setDescription($this->language->lang('CLI_UPDATE_BOARD'))
;
}
/**
* Executes the command update.
*
* Update the board
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->iohandler_factory->set_environment('cli');
/** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
$iohandler = $this->iohandler_factory->get();
$style = new SymfonyStyle($input, $output);
$iohandler->set_style($style, $output);
$this->installer->set_iohandler($iohandler);
$config_file = $input->getArgument('config-file');
if (!$this->install_helper->is_phpbb_installed())
{
$iohandler->add_error_message('INSTALL_PHPBB_NOT_INSTALLED');
return 1;
}
if (!is_file($config_file))
{
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
}
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
}
catch (ParseException $e)
{
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
return 1;
}
$processor = new Processor();
$configuration = new updater_configuration();
try
{
$config = $processor->processConfiguration($configuration, $config);
}
catch (Exception $e)
{
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
}
$this->register_configuration($iohandler, $config);
try
{
$this->installer->run();
}
catch (installer_exception $e)
{
$iohandler->add_error_message($e->getMessage());
return 1;
}
}
/**
* Register the configuration to simulate the forms.
*
* @param cli_iohandler $iohandler
* @param array $config
*/
private function register_configuration(cli_iohandler $iohandler, $config)
{
$iohandler->set_input('update_type', $config['type']);
$iohandler->set_input('submit_update', 'submit');
$iohandler->set_input('compression_method', '.tar');
$iohandler->set_input('method', 'direct_file');
$iohandler->set_input('submit_update_file', 'submit');
$iohandler->set_input('submit_continue_file_update', 'submit');
}
}

View File

@ -53,6 +53,14 @@ class obtain_update_settings extends task_base
if ($this->iohandler->get_input('submit_update', false))
{
$update_files = $this->iohandler->get_input('update_type', 'all') === 'all';
if ($this->installer_config->get('disable_filesystem_update', false) && $update_files)
{
$this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND');
throw new user_interaction_required_exception();
}
$this->installer_config->set('do_update_files', $update_files);
}
else

View File

@ -122,7 +122,7 @@ class check_update extends task_base
// Check for a valid update directory
if (!$this->filesystem->exists($update_files) || !$this->filesystem->is_readable($update_files))
{
$this->iohandler->add_error_message('UPDATE_FILES_NOT_FOUND');
$this->iohandler->add_warning_message('UPDATE_FILES_NOT_FOUND');
$this->set_test_passed(false);
// If there are no update files, we can't check the version etc

View File

@ -0,0 +1,40 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\install;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class updater_configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree builder.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('updater');
$rootNode
->addDefaultsIfNotSet()
->children()
->enumNode('type')->values(['all','db_only'])->defaultValue('all')->end()
->end()
;
return $treeBuilder;
}
}