1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/14039] Revamp updater

PHPBB3-14039
This commit is contained in:
Mate Bartus
2015-07-24 09:20:50 +02:00
parent f1047ac854
commit 8f5a0ad6f7
94 changed files with 4514 additions and 263 deletions

View File

@@ -0,0 +1,46 @@
<?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\db\output_handler;
class html_migrator_output_handler implements migrator_output_handler_interface
{
/**
* Language object.
*
* @var \phpbb\language\language
*/
private $language;
/**
* Constructor
*
* @param \phpbb\language\language $language Language object
*/
public function __construct(\phpbb\language\language $language)
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function write($message, $verbosity)
{
if ($verbosity <= migrator_output_handler_interface::VERBOSITY_VERBOSE)
{
$final_message = $this->language->lang_array($message);
echo $final_message . "<br />\n";
}
}
}

View File

@@ -0,0 +1,46 @@
<?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\db\output_handler;
use phpbb\install\helper\iohandler\iohandler_interface;
class installer_migrator_output_handler implements migrator_output_handler_interface
{
/**
* @var iohandler_interface
*/
protected $iohandler;
/**
* Constructor
*
* @param iohandler_interface $iohandler Installer's IO-handler
*/
public function __construct(iohandler_interface $iohandler)
{
$this->iohandler = $iohandler;
}
/**
* {@inheritdoc}
*/
public function write($message, $verbosity)
{
if ($verbosity <= migrator_output_handler_interface::VERBOSITY_VERBOSE)
{
$this->iohandler->add_log_message($message);
$this->iohandler->send_response();
}
}
}

View File

@@ -0,0 +1,100 @@
<?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\db\output_handler;
class log_wrapper_migrator_output_handler implements migrator_output_handler_interface
{
/**
* Language object.
*
* @var \phpbb\language\language
*/
protected $language;
/**
* A migrator output handler
*
* @var migrator_output_handler_interface
*/
protected $migrator;
/**
* Log file handle
* @var resource
*/
protected $file_handle = false;
/**
* @var \phpbb\filesystem\filesystem_interface
*/
protected $filesystem;
/**
* Constructor
*
* @param \phpbb\language\language $language Language object
* @param migrator_output_handler_interface $migrator Migrator output handler
* @param string $log_file File to log to
* @param \phpbb\filesystem\filesystem_interface $filesystem phpBB filesystem object
*/
public function __construct(\phpbb\language\language $language, migrator_output_handler_interface $migrator, $log_file, \phpbb\filesystem\filesystem_interface $filesystem)
{
$this->language = $language;
$this->migrator = $migrator;
$this->filesystem = $filesystem;
$this->file_open($log_file);
}
/**
* Open file for logging
*
* @param string $file File to open
*/
protected function file_open($file)
{
if ($this->filesystem->is_writable(dirname($file)))
{
$this->file_handle = fopen($file, 'w');
}
else
{
throw new \RuntimeException('Unable to write to migrator log file');
}
}
/**
* {@inheritdoc}
*/
public function write($message, $verbosity)
{
$this->migrator->write($message, $verbosity);
if ($this->file_handle !== false)
{
$translated_message = $this->language->lang_array($message);
if ($verbosity <= migrator_output_handler_interface::VERBOSITY_NORMAL)
{
$translated_message = '[INFO] ' . $translated_message;
}
else
{
$translated_message = '[DEBUG] ' . $translated_message;
}
fwrite($this->file_handle, $translated_message);
fflush($this->file_handle);
}
}
}

View File

@@ -0,0 +1,31 @@
<?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\db\output_handler;
interface migrator_output_handler_interface
{
const VERBOSITY_QUIET = 0;
const VERBOSITY_NORMAL = 1;
const VERBOSITY_VERBOSE = 2;
const VERBOSITY_VERY_VERBOSE = 3;
const VERBOSITY_DEBUG = 4;
/**
* Write output using the configured closure.
*
* @param string|array $message The message to write or an array containing the language key and all of its parameters.
* @param int $verbosity The verbosity of the message.
*/
public function write($message, $verbosity);
}

View File

@@ -0,0 +1,24 @@
<?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\db\output_handler;
class null_migrator_output_handler implements migrator_output_handler_interface
{
/**
* {@inheritdoc}
*/
public function write($message, $verbosity)
{
}
}