diff options
Diffstat (limited to 'phpBB/phpbb/console/command')
| -rw-r--r-- | phpBB/phpbb/console/command/cache/purge.php | 4 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/db/console_migrator_output_handler.php | 69 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/db/migrate.php | 42 | 
3 files changed, 80 insertions, 35 deletions
| diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php index ec8229200c..d0c2ef6f72 100644 --- a/phpBB/phpbb/console/command/cache/purge.php +++ b/phpBB/phpbb/console/command/cache/purge.php @@ -26,7 +26,7 @@ class purge extends \phpbb\console\command\command  	/** @var \phpbb\auth\auth */  	protected $auth; -	/** @var \phpbb\log\log */ +	/** @var \phpbb\log\log_interface */  	protected $log;  	/** @var \phpbb\config\config */ @@ -42,7 +42,7 @@ class purge extends \phpbb\console\command\command  	* @param \phpbb\log\log							$log	Logger instance  	* @param \phpbb\config\config					$config	Config instance  	*/ -	public function __construct(\phpbb\user $user, \phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\config\config $config) +	public function __construct(\phpbb\user $user, \phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\config\config $config)  	{  		$this->cache = $cache;  		$this->db = $db; diff --git a/phpBB/phpbb/console/command/db/console_migrator_output_handler.php b/phpBB/phpbb/console/command/db/console_migrator_output_handler.php new file mode 100644 index 0000000000..b9741a3838 --- /dev/null +++ b/phpBB/phpbb/console/command/db/console_migrator_output_handler.php @@ -0,0 +1,69 @@ +<?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\console\command\db; + +use phpbb\user; +use phpbb\db\migrator_output_handler_interface; +use Symfony\Component\Console\Output\OutputInterface; + +class console_migrator_output_handler implements migrator_output_handler_interface +{ +	/** +	 * User object. +	 * +	 * @var user +	 */ +	private $user; + +	/** +	 * Console output object. +	 * +	 * @var OutputInterface +	 */ +	private $output; + +	/** +	 * Constructor +	 * +	 * @param user				$user	User object +	 * @param OutputInterface	$output	Console output object +	 */ +	public function __construct(user $user, OutputInterface $output) +	{ +		$this->user = $user; +		$this->output = $output; +	} + +	/** +	 * {@inheritdoc} +	 */ +	public function write($message, $verbosity) +	{ +		if ($verbosity <= $this->output->getVerbosity()) +		{ +			$translated_message = call_user_func_array(array($this->user, 'lang'), $message); + +			if ($verbosity === migrator_output_handler_interface::VERBOSITY_NORMAL) +			{ +				$translated_message = '<info>' . $translated_message . '</info>'; +			} +			else if ($verbosity === migrator_output_handler_interface::VERBOSITY_VERBOSE) +			{ +				$translated_message = '<comment>' . $translated_message . '</comment>'; +			} + +			$this->output->writeln($translated_message); +		} +	} +} diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 86545c237d..87c2a057d1 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,13 +32,17 @@ class migrate extends \phpbb\console\command\command  	/** @var \phpbb\log\log */  	protected $log; -	function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log) +	/** @var string phpBB root path */ +	protected $phpbb_root_path; + +	function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, $phpbb_root_path)  	{  		$this->migrator = $migrator;  		$this->extension_manager = $extension_manager;  		$this->config = $config;  		$this->cache = $cache;  		$this->log = $log; +		$this->phpbb_root_path = $phpbb_root_path;  		parent::__construct($user);  		$this->user->add_lang(array('common', 'install', 'migrator'));  	} @@ -53,14 +57,16 @@ class migrate extends \phpbb\console\command\command  	protected function execute(InputInterface $input, OutputInterface $output)  	{ +		$this->migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($this->user, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log')); +  		$this->migrator->create_migrations_table(); +		$this->cache->purge(); +  		$this->load_migrations();  		$orig_version = $this->config['version'];  		while (!$this->migrator->finished())  		{ -			$migration_start_time = microtime(true); -  			try  			{  				$this->migrator->update(); @@ -71,36 +77,6 @@ class migrate extends \phpbb\console\command\command  				$this->finalise_update();  				return 1;  			} - -			$migration_stop_time = microtime(true) - $migration_start_time; - -			$state = array_merge( -				array( -					'migration_schema_done' => false, -					'migration_data_done'	=> false, -				), -				$this->migrator->last_run_migration['state'] -			); - -			if (!empty($this->migrator->last_run_migration['effectively_installed'])) -			{ -				$msg = $this->user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $this->migrator->last_run_migration['name']); -				$output->writeln("<comment>$msg</comment>"); -			} -			else if ($this->migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done']) -			{ -				$msg = $this->user->lang('MIGRATION_DATA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time); -				$output->writeln("<info>$msg</info>"); -			} -			else if ($this->migrator->last_run_migration['task'] == 'process_data_step') -			{ -				$output->writeln($this->user->lang('MIGRATION_DATA_IN_PROGRESS', $this->migrator->last_run_migration['name'], $migration_stop_time)); -			} -			else if ($state['migration_schema_done']) -			{ -				$msg = $this->user->lang('MIGRATION_SCHEMA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time); -				$output->writeln("<info>$msg</info>"); -			}  		}  		if ($orig_version != $this->config['version']) | 
