[ticket/13211] Also use log wrapper output handler for console migrations

PHPBB3-13211
This commit is contained in:
Marc Alexander 2014-10-25 11:55:15 -07:00
parent b27b9a6984
commit 8443463006
3 changed files with 14 additions and 9 deletions

View file

@ -84,6 +84,7 @@ services:
- @config - @config
- @cache - @cache
- @log - @log
- %core.root_path%
tags: tags:
- { name: console.command } - { name: console.command }

View file

@ -32,13 +32,17 @@ class migrate extends \phpbb\console\command\command
/** @var \phpbb\log\log */ /** @var \phpbb\log\log */
protected $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->migrator = $migrator;
$this->extension_manager = $extension_manager; $this->extension_manager = $extension_manager;
$this->config = $config; $this->config = $config;
$this->cache = $cache; $this->cache = $cache;
$this->log = $log; $this->log = $log;
$this->phpbb_root_path = $phpbb_root_path;
parent::__construct($user); parent::__construct($user);
$this->user->add_lang(array('common', 'install', 'migrator')); $this->user->add_lang(array('common', 'install', 'migrator'));
} }
@ -53,7 +57,7 @@ class migrate extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$this->migrator->set_output_handler(new \phpbb\db\console_migrator_output_handler($this->user, $output)); $this->migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($this->user, new \phpbb\db\console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log'));
$this->migrator->create_migrations_table(); $this->migrator->create_migrations_table();

View file

@ -25,11 +25,11 @@ class log_wrapper_migrator_output_handler implements migrator_output_handler_int
protected $user; protected $user;
/** /**
* HTML migrator output handler * A migrator output handler
* *
* @var html_migrator_output_handler * @var migrator_output_handler_interface
*/ */
protected $html_migrator; protected $migrator;
/** /**
* Log file handle * Log file handle
@ -41,13 +41,13 @@ class log_wrapper_migrator_output_handler implements migrator_output_handler_int
* Constructor * Constructor
* *
* @param user $user User object * @param user $user User object
* @param html_migrator_output_handler $html_migrator HTML migrator output handler * @param migrator_output_handler_interface $migrator Migrator output handler
* @param string $log_file File to log to * @param string $log_file File to log to
*/ */
public function __construct(user $user, html_migrator_output_handler $html_migrator, $log_file) public function __construct(user $user, migrator_output_handler_interface $migrator, $log_file)
{ {
$this->user = $user; $this->user = $user;
$this->html_migrator = $html_migrator; $this->migrator = $migrator;
$this->file_open($log_file); $this->file_open($log_file);
} }
@ -73,7 +73,7 @@ class log_wrapper_migrator_output_handler implements migrator_output_handler_int
*/ */
public function write($message, $verbosity) public function write($message, $verbosity)
{ {
$this->html_migrator->write($message, $verbosity); $this->migrator->write($message, $verbosity);
if ($this->file_handle !== false) if ($this->file_handle !== false)
{ {