mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-23 17:10:53 +01:00
Merge pull request #3856 from Nicofuma/ticket/12610
[ticket/12610] Add command to check if the board is up to date.
This commit is contained in:
commit
375e264a47
@ -71,17 +71,16 @@ require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
|
||||
|
||||
register_compatibility_globals();
|
||||
|
||||
/** @var \phpbb\language\language $language */
|
||||
$language = $phpbb_container->get('language');
|
||||
$language->add_lang(array('common', 'acp/common', 'cli'));
|
||||
|
||||
/* @var $user \phpbb\user */
|
||||
$user = $phpbb_container->get('user');
|
||||
$user->data['user_id'] = ANONYMOUS;
|
||||
$user->ip = '127.0.0.1';
|
||||
$user->add_lang('acp/common');
|
||||
$user->add_lang('cli');
|
||||
|
||||
/* @var $lang \phpbb\language\language */
|
||||
$lang = $phpbb_container->get('language');
|
||||
|
||||
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $lang);
|
||||
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language);
|
||||
$application->setDispatcher($phpbb_container->get('dispatcher'));
|
||||
$application->register_container_commands($phpbb_container->get('console.command_collection'));
|
||||
$application->run($input);
|
||||
|
@ -108,7 +108,7 @@ services:
|
||||
- '%tables.ext%'
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
- '@cache.driver'
|
||||
- '@cache'
|
||||
|
||||
file_downloader:
|
||||
class: phpbb\file_downloader
|
||||
|
@ -220,6 +220,16 @@ services:
|
||||
tags:
|
||||
- { name: console.command }
|
||||
|
||||
console.command.update.check:
|
||||
class: phpbb\console\command\update\check
|
||||
arguments:
|
||||
- '@user'
|
||||
- '@config'
|
||||
- '@service_container'
|
||||
- '@language'
|
||||
tags:
|
||||
- { name: console.command }
|
||||
|
||||
console.command.user.activate:
|
||||
class: phpbb\console\command\user\activate
|
||||
arguments:
|
||||
|
@ -11,6 +11,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use phpbb\exception\exception_interface;
|
||||
use phpbb\exception\version_check_exception;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@ -86,13 +89,13 @@ class acp_extensions
|
||||
// If they've specified an extension, let's load the metadata manager and validate it.
|
||||
if ($ext_name)
|
||||
{
|
||||
$md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $phpbb_root_path);
|
||||
$md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $phpbb_root_path);
|
||||
|
||||
try
|
||||
{
|
||||
$md_manager->get_metadata('all');
|
||||
}
|
||||
catch (\phpbb\extension\exception $e)
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
trigger_error($message, E_USER_WARNING);
|
||||
@ -303,11 +306,11 @@ class acp_extensions
|
||||
|
||||
case 'details':
|
||||
// Output it to the template
|
||||
$md_manager->output_template_data();
|
||||
$md_manager->output_template_data($template);
|
||||
|
||||
try
|
||||
{
|
||||
$updates_available = $this->version_check($md_manager, $request->variable('versioncheck_force', false));
|
||||
$updates_available = $phpbb_extension_manager->version_check($md_manager, $request->variable('versioncheck_force', false), $this->config['extension_force_unstable'] ? 'unstable' : null);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_UP_TO_DATE' => empty($updates_available),
|
||||
@ -320,11 +323,13 @@ class acp_extensions
|
||||
$template->assign_block_vars('updates_available', $version_data);
|
||||
}
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_VERSIONCHECK_STATUS' => $e->getCode(),
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '',
|
||||
));
|
||||
}
|
||||
|
||||
@ -350,7 +355,7 @@ class acp_extensions
|
||||
|
||||
foreach ($phpbb_extension_manager->all_enabled() as $name => $location)
|
||||
{
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
|
||||
|
||||
try
|
||||
{
|
||||
@ -360,14 +365,28 @@ class acp_extensions
|
||||
'META_VERSION' => $meta['version'],
|
||||
);
|
||||
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $this->version_check($md_manager, $force_update, !$force_update);
|
||||
if (isset($meta['extra']['version-check']))
|
||||
{
|
||||
try
|
||||
{
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
|
||||
|
||||
$enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
$enabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$enabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
}
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
// Ignore exceptions due to the version check
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$enabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
|
||||
}
|
||||
}
|
||||
catch (\phpbb\extension\exception $e)
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
$this->template->assign_block_vars('disabled', array(
|
||||
@ -408,7 +427,7 @@ class acp_extensions
|
||||
|
||||
foreach ($phpbb_extension_manager->all_disabled() as $name => $location)
|
||||
{
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
|
||||
|
||||
try
|
||||
{
|
||||
@ -418,14 +437,21 @@ class acp_extensions
|
||||
'META_VERSION' => $meta['version'],
|
||||
);
|
||||
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $this->version_check($md_manager, $force_update, !$force_update);
|
||||
if (isset($meta['extra']['version-check']))
|
||||
{
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
|
||||
|
||||
$disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
$disabled_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$disabled_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$disabled_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
|
||||
}
|
||||
}
|
||||
catch (\phpbb\extension\exception $e)
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
$this->template->assign_block_vars('disabled', array(
|
||||
@ -469,7 +495,7 @@ class acp_extensions
|
||||
|
||||
foreach ($uninstalled as $name => $location)
|
||||
{
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
|
||||
$md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name);
|
||||
|
||||
try
|
||||
{
|
||||
@ -479,14 +505,25 @@ class acp_extensions
|
||||
'META_VERSION' => $meta['version'],
|
||||
);
|
||||
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $this->version_check($md_manager, $force_update, !$force_update);
|
||||
if (isset($meta['extra']['version-check']))
|
||||
{
|
||||
$force_update = $this->request->variable('versioncheck_force', false);
|
||||
$updates = $phpbb_extension_manager->version_check($md_manager, $force_update, !$force_update);
|
||||
|
||||
$available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
$available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates);
|
||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = true;
|
||||
$available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
|
||||
}
|
||||
}
|
||||
catch (\phpbb\extension\exception $e)
|
||||
catch (version_check_exception $e)
|
||||
{
|
||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
|
||||
}
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
$this->template->assign_block_vars('disabled', array(
|
||||
@ -494,10 +531,6 @@ class acp_extensions
|
||||
'S_VERSIONCHECK' => false,
|
||||
));
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$available_extension_meta_data[$name]['S_VERSIONCHECK'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table'));
|
||||
@ -533,34 +566,6 @@ class acp_extensions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the version and return the available updates.
|
||||
*
|
||||
* @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
|
||||
{
|
||||
$meta = $md_manager->get_metadata('all');
|
||||
|
||||
if (!isset($meta['extra']['version-check']))
|
||||
{
|
||||
throw new \RuntimeException($this->user->lang('NO_VERSIONCHECK'), 1);
|
||||
}
|
||||
|
||||
$version_check = $meta['extra']['version-check'];
|
||||
|
||||
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), $this->user);
|
||||
$version_helper->set_current_version($meta['version']);
|
||||
$version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename'], isset($version_check['ssl']) ? $version_check['ssl'] : false);
|
||||
$version_helper->force_stability($this->config['extension_force_unstable'] ? 'unstable' : null);
|
||||
|
||||
return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort helper for the table containing the metadata about the extensions.
|
||||
*/
|
||||
|
@ -450,9 +450,10 @@ class acp_main
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$message = call_user_func_array(array($user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
$template->assign_vars(array(
|
||||
'S_VERSIONCHECK_FAIL' => true,
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== $user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
|
||||
'VERSIONCHECK_FAIL_REASON' => ($e->getMessage() !== 'VERSIONCHECK_FAIL') ? $message : '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -328,6 +328,10 @@ $lang = array_merge($lang, array(
|
||||
'USERNAMES_EXPLAIN' => 'Place each username on a separate line.',
|
||||
'USER_CONTROL_PANEL' => 'User Control Panel',
|
||||
|
||||
'UPDATE_NEEDED' => 'The board is not up to date.',
|
||||
'UPDATE_NOT_NEEDED' => 'The board is up to date.',
|
||||
'UPDATES_AVAILABLE' => 'Updates available:',
|
||||
|
||||
'WARNING' => 'Warning',
|
||||
));
|
||||
|
||||
|
@ -43,6 +43,7 @@ $lang = array_merge($lang, array(
|
||||
'EXTENSION_NOT_AVAILABLE' => 'The selected extension is not available for this board, please verify your phpBB and PHP versions are allowed (see the details page).',
|
||||
'EXTENSION_DIR_INVALID' => 'The selected extension has an invalid directory structure and cannot be enabled.',
|
||||
'EXTENSION_NOT_ENABLEABLE' => 'The selected extension cannot be enabled, please verify the extension’s requirements.',
|
||||
'EXTENSION_NOT_INSTALLED' => 'The extension %s is not available. PLease check that you have installed it correctly.',
|
||||
|
||||
'DETAILS' => 'Details',
|
||||
|
||||
|
@ -66,21 +66,31 @@ $lang = array_merge($lang, array(
|
||||
'CLI_DESCRIPTION_OPTION_SHELL' => 'Launch the shell.',
|
||||
|
||||
'CLI_DESCRIPTION_PURGE_EXTENSION' => 'Purges the specified extension.',
|
||||
'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.',
|
||||
|
||||
'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_DRY_RUN' => 'Do not save any changes; just print what would happen',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN' => 'Lowest record ID to process',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX' => 'Highest record ID to process',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE' => 'Approximate number of records to process at a time',
|
||||
'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RESUME' => 'Start reparsing where the last execution stopped',
|
||||
'CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH' => 'Recalculates the user_email_hash column of the users table.',
|
||||
'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value',
|
||||
'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value',
|
||||
|
||||
'CLI_DESCRIPTION_THUMBNAIL_DELETE' => 'Delete all existing thumbnails.',
|
||||
'CLI_DESCRIPTION_THUMBNAIL_GENERATE' => 'Generate all missing thumbnails.',
|
||||
'CLI_DESCRIPTION_THUMBNAIL_RECREATE' => 'Recreate all thumbnails.',
|
||||
'CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH' => 'Recalculates the user_email_hash column of the users table.',
|
||||
|
||||
'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value',
|
||||
'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value',
|
||||
|
||||
'CLI_DESCRIPTION_THUMBNAIL_DELETE' => 'Delete all existing thumbnails.',
|
||||
'CLI_DESCRIPTION_THUMBNAIL_GENERATE' => 'Generate all missing thumbnails.',
|
||||
'CLI_DESCRIPTION_THUMBNAIL_RECREATE' => 'Recreate all thumbnails.',
|
||||
|
||||
'CLI_DESCRIPTION_UPDATE_CHECK' => 'Check if the board is up to date.',
|
||||
'CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1' => 'Name of the extension to check (if all, checks all the extensions)',
|
||||
'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE' => 'Run check command with cache.',
|
||||
'CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.',
|
||||
|
||||
'CLI_ERROR_INVALID_STABILITY' => '"%s" is not a valid stability.',
|
||||
|
||||
'CLI_DESCRIPTION_USER_ACTIVATE' => 'Activate (or deactivate) a user account.',
|
||||
'CLI_DESCRIPTION_USER_ACTIVATE_USERNAME' => 'Username of the account to activate.',
|
||||
|
331
phpBB/phpbb/console/command/update/check.php
Normal file
331
phpBB/phpbb/console/command/update/check.php
Normal file
@ -0,0 +1,331 @@
|
||||
<?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\update;
|
||||
|
||||
use phpbb\config\config;
|
||||
use phpbb\exception\exception_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\user;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class check extends \phpbb\console\command\command
|
||||
{
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \Symfony\Component\DependencyInjection\ContainerBuilder */
|
||||
protected $phpbb_container;
|
||||
/**
|
||||
* @var language
|
||||
*/
|
||||
private $language;
|
||||
|
||||
/**
|
||||
* Construct method
|
||||
*/
|
||||
public function __construct(user $user, config $config, ContainerInterface $phpbb_container, language $language)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->phpbb_container = $phpbb_container;
|
||||
$this->language = $language;
|
||||
|
||||
$this->language->add_lang(array('acp/common', 'acp/extensions'));
|
||||
|
||||
parent::__construct($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the service.
|
||||
*
|
||||
* Sets the name and description of the command.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('update:check')
|
||||
->setDescription($this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK'))
|
||||
->addArgument('ext-name', InputArgument::OPTIONAL, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1'))
|
||||
->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY'))
|
||||
->addOption('cache', 'c', InputOption::VALUE_NONE, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE'))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the command.
|
||||
*
|
||||
* Checks if an update is available.
|
||||
* If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed.
|
||||
* If their is none, nothing is printed unless verbose mode is set.
|
||||
*
|
||||
* @param InputInterface $input Input stream, used to get the options.
|
||||
* @param OutputInterface $output Output stream, used to print messages.
|
||||
* @return int 0 if the board is up to date, 1 if it is not and 2 if an error occured.
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$recheck = true;
|
||||
if ($input->getOption('cache'))
|
||||
{
|
||||
$recheck = false;
|
||||
}
|
||||
|
||||
$stability = null;
|
||||
if ($input->getOption('stability'))
|
||||
{
|
||||
$stability = $input->getOption('stability');
|
||||
if (!($stability == 'stable') && !($stability == 'unstable'))
|
||||
{
|
||||
$io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability));
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
$ext_name = $input->getArgument('ext-name');
|
||||
if ($ext_name != null)
|
||||
{
|
||||
if ($ext_name == 'all')
|
||||
{
|
||||
return $this->check_all_ext($io, $stability, $recheck);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->check_ext($input, $io, $stability, $recheck, $ext_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->check_core($input, $io, $stability, $recheck);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given extension is up to date
|
||||
*
|
||||
* @param InputInterface $input Input stream, used to get the options.
|
||||
* @param SymfonyStyle $io IO handler, for formatted and unified IO
|
||||
* @param string $stability Force a given stability
|
||||
* @param bool $recheck Disallow the use of the cache
|
||||
* @param string $ext_name The extension name
|
||||
* @return int
|
||||
*/
|
||||
protected function check_ext(InputInterface $input, SymfonyStyle $io, $stability, $recheck, $ext_name)
|
||||
{
|
||||
try
|
||||
{
|
||||
$ext_manager = $this->phpbb_container->get('ext.manager');
|
||||
$md_manager = $ext_manager->create_extension_metadata_manager($ext_name, null);
|
||||
$updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
|
||||
|
||||
$metadata = $md_manager->get_metadata('all');
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$io->title($md_manager->get_metadata('display-name'));
|
||||
|
||||
$io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $metadata['version']);
|
||||
}
|
||||
|
||||
if (!empty($updates_available))
|
||||
{
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$io->caution($this->language->lang('NOT_UP_TO_DATE', $metadata['name']));
|
||||
|
||||
$this->display_versions($io, $updates_available);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$io->success($this->language->lang('UPDATE_NOT_NEEDED'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the core is up to date
|
||||
*
|
||||
* @param InputInterface $input Input stream, used to get the options.
|
||||
* @param SymfonyStyle $io IO handler, for formatted and unified IO
|
||||
* @param string $stability Force a given stability
|
||||
* @param bool $recheck Disallow the use of the cache
|
||||
* @return int
|
||||
*/
|
||||
protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck)
|
||||
{
|
||||
$version_helper = $this->phpbb_container->get('version_helper');
|
||||
$version_helper->force_stability($stability);
|
||||
|
||||
$updates_available = $version_helper->get_suggested_updates($recheck);
|
||||
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$io->title('phpBB core');
|
||||
|
||||
$io->note( $this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']);
|
||||
}
|
||||
|
||||
if (!empty($updates_available))
|
||||
{
|
||||
$io->caution($this->language->lang('UPDATE_NEEDED'));
|
||||
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$this->display_versions($io, $updates_available);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($input->getOption('verbose'))
|
||||
{
|
||||
$io->success($this->language->lang('UPDATE_NOT_NEEDED'));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all the available extensions are up to date
|
||||
*
|
||||
* @param SymfonyStyle $io IO handler, for formatted and unified IO
|
||||
* @param bool $recheck Disallow the use of the cache
|
||||
* @return int
|
||||
*/
|
||||
protected function check_all_ext(SymfonyStyle $io, $stability, $recheck)
|
||||
{
|
||||
/** @var \phpbb\extension\manager $ext_manager */
|
||||
$ext_manager = $this->phpbb_container->get('ext.manager');
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($ext_manager->all_available() as $ext_name => $ext_path)
|
||||
{
|
||||
$row = [];
|
||||
$row[] = sprintf("<info>%s</info>", $ext_name);
|
||||
$md_manager = $ext_manager->create_extension_metadata_manager($ext_name);
|
||||
try
|
||||
{
|
||||
$metadata = $md_manager->get_metadata('all');
|
||||
if (isset($metadata['extra']['version-check']))
|
||||
{
|
||||
try {
|
||||
$updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
|
||||
if (!empty($updates_available))
|
||||
{
|
||||
$versions = array_map(function($entry)
|
||||
{
|
||||
return $entry['current'];
|
||||
}, $updates_available);
|
||||
|
||||
$row[] = sprintf("<comment>%s</comment>", $metadata['version']);
|
||||
$row[] = implode(', ', $versions);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row[] = sprintf("<info>%s</info>", $metadata['version']);
|
||||
$row[] = '';
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
$row[] = $metadata['version'];
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$row[] = $metadata['version'];
|
||||
$row[] = '';
|
||||
}
|
||||
}
|
||||
catch (exception_interface $e)
|
||||
{
|
||||
$exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
|
||||
$row[] = '<error>' . $exception_message . '</error>';
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$row[] = '<error>' . $e->getMessage() . '</error>';
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$io->table([
|
||||
$this->language->lang('EXTENSION_NAME'),
|
||||
$this->language->lang('CURRENT_VERSION'),
|
||||
$this->language->lang('LATEST_VERSION'),
|
||||
], $rows);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the details of the available updates
|
||||
*
|
||||
* @param SymfonyStyle $io IO handler, for formatted and unified IO
|
||||
* @param array $updates_available The list of the available updates
|
||||
*/
|
||||
protected function display_versions(SymfonyStyle $io, $updates_available)
|
||||
{
|
||||
$io->section($this->language->lang('UPDATES_AVAILABLE'));
|
||||
|
||||
$rows = [];
|
||||
foreach ($updates_available as $version_data)
|
||||
{
|
||||
$row = ['', '', ''];
|
||||
$row[0] = $version_data['current'];
|
||||
|
||||
if (isset($version_data['announcement']))
|
||||
{
|
||||
$row[1] = $version_data['announcement'];
|
||||
}
|
||||
|
||||
if (isset($version_data['download']))
|
||||
{
|
||||
$row[2] = $version_data['download'];
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$io->table([
|
||||
$this->language->lang('VERSION'),
|
||||
$this->language->lang('ANNOUNCEMENT_TOPIC'),
|
||||
$this->language->lang('DOWNLOAD_LATEST'),
|
||||
], $rows);
|
||||
}
|
||||
}
|
21
phpBB/phpbb/exception/version_check_exception.php
Normal file
21
phpBB/phpbb/exception/version_check_exception.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?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\exception;
|
||||
|
||||
/**
|
||||
* Define an exception related to the version checker.
|
||||
*/
|
||||
class version_check_exception extends runtime_exception
|
||||
{
|
||||
}
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
use phpbb\exception\runtime_exception;
|
||||
use phpbb\file_downloader;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@ -42,10 +44,10 @@ class manager
|
||||
* @param string $extension_table The name of the table holding extensions
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
* @param string $php_ext php file extension, defaults to php
|
||||
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
|
||||
* @param \phpbb\cache\service $cache A cache instance or null
|
||||
* @param string $cache_name The name of the cache variable, defaults to _ext
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext')
|
||||
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem\filesystem_interface $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\service $cache = null, $cache_name = '_ext')
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->cache_name = $cache_name;
|
||||
@ -146,12 +148,11 @@ class manager
|
||||
* Instantiates the metadata manager for the extension with the given name
|
||||
*
|
||||
* @param string $name The extension name
|
||||
* @param \phpbb\template\template $template The template manager
|
||||
* @return \phpbb\extension\metadata_manager Instance of the metadata manager
|
||||
*/
|
||||
public function create_extension_metadata_manager($name, \phpbb\template\template $template)
|
||||
public function create_extension_metadata_manager($name)
|
||||
{
|
||||
return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->phpbb_root_path);
|
||||
return new \phpbb\extension\metadata_manager($name, $this->config, $this, $this->phpbb_root_path);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,6 +566,35 @@ class manager
|
||||
return isset($this->extensions[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the version and return the available updates (for an extension).
|
||||
*
|
||||
* @param \phpbb\extension\metadata_manager $md_manager The metadata manager for the version to check.
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @param string $stability Force the stability (null by default).
|
||||
* @return string
|
||||
* @throws runtime_exception
|
||||
*/
|
||||
public function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false, $stability = null)
|
||||
{
|
||||
$meta = $md_manager->get_metadata('all');
|
||||
|
||||
if (!isset($meta['extra']['version-check']))
|
||||
{
|
||||
throw new runtime_exception('NO_VERSIONCHECK');
|
||||
}
|
||||
|
||||
$version_check = $meta['extra']['version-check'];
|
||||
|
||||
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new file_downloader());
|
||||
$version_helper->set_current_version($meta['version']);
|
||||
$version_helper->set_file_location($version_check['host'], $version_check['directory'], $version_check['filename']);
|
||||
$version_helper->force_stability($stability);
|
||||
|
||||
return $updates = $version_helper->get_suggested_updates($force_update, $force_cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given extension is purged
|
||||
*
|
||||
|
@ -30,12 +30,6 @@ class metadata_manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* phpBB Template instance
|
||||
* @var \phpbb\template\template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* phpBB root path
|
||||
* @var string
|
||||
@ -66,14 +60,12 @@ class metadata_manager
|
||||
* @param string $ext_name Name (including vendor) of the extension
|
||||
* @param \phpbb\config\config $config phpBB Config instance
|
||||
* @param \phpbb\extension\manager $extension_manager An instance of the phpBB extension manager
|
||||
* @param \phpbb\template\template $template phpBB Template instance
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
*/
|
||||
public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, \phpbb\template\template $template, $phpbb_root_path)
|
||||
public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, $phpbb_root_path)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->extension_manager = $extension_manager;
|
||||
$this->template = $template;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
||||
$this->ext_name = $ext_name;
|
||||
@ -336,11 +328,11 @@ class metadata_manager
|
||||
/**
|
||||
* Outputs the metadata into the template
|
||||
*
|
||||
* @return null
|
||||
* @param \phpbb\template\template $template phpBB Template instance
|
||||
*/
|
||||
public function output_template_data()
|
||||
public function output_template_data(\phpbb\template\template $template)
|
||||
{
|
||||
$this->template->assign_vars(array(
|
||||
$template->assign_vars(array(
|
||||
'META_NAME' => $this->metadata['name'],
|
||||
'META_TYPE' => $this->metadata['type'],
|
||||
'META_DESCRIPTION' => (isset($this->metadata['description'])) ? $this->metadata['description'] : '',
|
||||
@ -360,7 +352,7 @@ class metadata_manager
|
||||
|
||||
foreach ($this->metadata['authors'] as $author)
|
||||
{
|
||||
$this->template->assign_block_vars('meta_authors', array(
|
||||
$template->assign_block_vars('meta_authors', array(
|
||||
'AUTHOR_NAME' => $author['name'],
|
||||
'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '',
|
||||
'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '',
|
||||
|
@ -50,12 +50,12 @@ class finder
|
||||
*
|
||||
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem instance
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory
|
||||
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
|
||||
* @param \phpbb\cache\service $cache A cache instance or null
|
||||
* @param string $php_ext php file extension
|
||||
* @param string $cache_name The name of the cache variable, defaults to
|
||||
* _ext_finder
|
||||
*/
|
||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
|
||||
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path = '', \phpbb\cache\service $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb;
|
||||
|
||||
use phpbb\exception\version_check_exception;
|
||||
|
||||
/**
|
||||
* Class to handle version checking and comparison
|
||||
*/
|
||||
@ -58,23 +60,18 @@ class version_helper
|
||||
/** @var \phpbb\file_downloader */
|
||||
protected $file_downloader;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\cache\service $cache
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\file_downloader $file_downloader
|
||||
* @param \phpbb\user $user
|
||||
*/
|
||||
public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader, \phpbb\user $user)
|
||||
public function __construct(\phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\file_downloader $file_downloader)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->config = $config;
|
||||
$this->file_downloader = $file_downloader;
|
||||
$this->user = $user;
|
||||
|
||||
if (defined('PHPBB_QA'))
|
||||
{
|
||||
@ -175,7 +172,7 @@ class version_helper
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @return string
|
||||
* @throws \RuntimeException
|
||||
* @throws version_check_exception
|
||||
*/
|
||||
public function get_latest_on_current_branch($force_update = false, $force_cache = false)
|
||||
{
|
||||
@ -206,7 +203,7 @@ class version_helper
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @return string
|
||||
* @throws \RuntimeException
|
||||
* @throws version_check_exception
|
||||
*/
|
||||
public function get_suggested_updates($force_update = false, $force_cache = false)
|
||||
{
|
||||
@ -227,7 +224,7 @@ class version_helper
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @return string Version info
|
||||
* @throws \RuntimeException
|
||||
* @throws version_check_exception
|
||||
*/
|
||||
public function get_versions_matching_stability($force_update = false, $force_cache = false)
|
||||
{
|
||||
@ -247,7 +244,7 @@ class version_helper
|
||||
* @param bool $force_update Ignores cached data. Defaults to false.
|
||||
* @param bool $force_cache Force the use of the cache. Override $force_update.
|
||||
* @return string Version info, includes stable and unstable data
|
||||
* @throws \RuntimeException
|
||||
* @throws version_check_exception
|
||||
*/
|
||||
public function get_versions($force_update = false, $force_cache = false)
|
||||
{
|
||||
@ -257,23 +254,16 @@ class version_helper
|
||||
|
||||
if ($info === false && $force_cache)
|
||||
{
|
||||
throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
|
||||
throw new version_check_exception('VERSIONCHECK_FAIL');
|
||||
}
|
||||
else if ($info === false || $force_update)
|
||||
{
|
||||
try {
|
||||
$info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80);
|
||||
}
|
||||
catch (\phpbb\exception\runtime_exception $exception)
|
||||
{
|
||||
$prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters());
|
||||
throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $prepare_parameters));
|
||||
}
|
||||
$info = $this->file_downloader->get($this->host, $this->path, $this->file, $this->use_ssl ? 443 : 80);
|
||||
$error_string = $this->file_downloader->get_error_string();
|
||||
|
||||
if (!empty($error_string))
|
||||
{
|
||||
throw new \RuntimeException($error_string);
|
||||
throw new version_check_exception($error_string);
|
||||
}
|
||||
|
||||
$info = json_decode($info, true);
|
||||
@ -290,9 +280,7 @@ class version_helper
|
||||
|
||||
if (empty($info['stable']) && empty($info['unstable']))
|
||||
{
|
||||
$this->user->add_lang('acp/common');
|
||||
|
||||
throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL'));
|
||||
throw new version_check_exception('VERSIONCHECK_FAIL');
|
||||
}
|
||||
|
||||
$info['stable'] = (empty($info['stable'])) ? array() : $info['stable'];
|
||||
|
110
tests/console/update/check_test.php
Normal file
110
tests/console/update/check_test.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use phpbb\console\command\update\check;
|
||||
|
||||
require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_admin.php';
|
||||
require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
/**
|
||||
* @slow
|
||||
*/
|
||||
class phpbb_console_command_check_test extends phpbb_test_case
|
||||
{
|
||||
protected $command_name;
|
||||
|
||||
protected $version_helper;
|
||||
|
||||
/** @var \phpbb\language\language */
|
||||
protected $language;
|
||||
|
||||
public function test_up_to_date()
|
||||
{
|
||||
$command_tester = $this->get_command_tester('100000');
|
||||
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
|
||||
$this->assertSame('', $command_tester->getDisplay());
|
||||
$this->assertSame($status, 0);
|
||||
}
|
||||
|
||||
public function test_up_to_date_verbose()
|
||||
{
|
||||
$command_tester = $this->get_command_tester('100000');
|
||||
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
|
||||
$this->assertContains($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay());
|
||||
$this->assertSame($status, 0);
|
||||
}
|
||||
|
||||
|
||||
public function test_not_up_to_date()
|
||||
{
|
||||
$command_tester = $this->get_command_tester('0');
|
||||
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
|
||||
$this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
|
||||
$this->assertSame($status, 1);
|
||||
}
|
||||
|
||||
public function test_not_up_to_date_verbose()
|
||||
{
|
||||
$command_tester = $this->get_command_tester('0');
|
||||
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true));
|
||||
$this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay());
|
||||
$this->assertContains($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay());
|
||||
$this->assertSame($status, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException phpbb\exception\runtime_exception
|
||||
*/
|
||||
public function test_error()
|
||||
{
|
||||
$command_tester = $this->get_command_tester('1');
|
||||
$this->version_helper->set_file_location('acme.corp','foo', 'bar.json');
|
||||
|
||||
$status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true));
|
||||
$this->assertContains('VERSIONCHECK_FAIL', $command_tester->getDisplay());
|
||||
$this->assertSame($status, 2);
|
||||
}
|
||||
|
||||
public function get_command_tester($current_version)
|
||||
{
|
||||
global $user, $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
|
||||
|
||||
$user = $this->getMock('\phpbb\user', array(), array(
|
||||
$this->language,
|
||||
'\phpbb\datetime'
|
||||
));
|
||||
$user->method('lang')->will($this->returnArgument(0));
|
||||
|
||||
$cache = $this->getMockBuilder('\phpbb\cache\service')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$config = new \phpbb\config\config(array('version' => $current_version));
|
||||
$this->version_helper = new \phpbb\version_helper($cache, $config, new \phpbb\file_downloader());
|
||||
|
||||
$container = new phpbb_mock_container_builder;
|
||||
$container->set('version_helper', $this->version_helper);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new check($user, $config, $container, $this->language));
|
||||
|
||||
$command = $application->find('update:check');
|
||||
$this->command_name = $command->getName();
|
||||
return new CommandTester($command);
|
||||
}
|
||||
}
|
@ -180,7 +180,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||
'phpbb_ext',
|
||||
dirname(__FILE__) . '/',
|
||||
$php_ext,
|
||||
($with_cache) ? new phpbb_mock_cache() : null
|
||||
($with_cache) ? new \phpbb\cache\service(new phpbb_mock_cache(), $config, $db, $phpbb_root_path, $php_ext) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->cache = new phpbb_mock_cache();
|
||||
$this->config = new \phpbb\config\config(array(
|
||||
'version' => '3.1.0',
|
||||
));
|
||||
@ -45,6 +44,9 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
$this->db_tools = $factory->get($this->db);
|
||||
$this->phpbb_root_path = dirname(__FILE__) . '/';
|
||||
$this->phpEx = 'php';
|
||||
|
||||
$this->cache = new \phpbb\cache\service(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx);
|
||||
|
||||
$this->table_prefix = 'phpbb_';
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
@ -364,7 +366,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
$ext_name,
|
||||
$this->config,
|
||||
$this->extension_manager,
|
||||
$this->template,
|
||||
$this->phpbb_root_path
|
||||
);
|
||||
}
|
||||
|
@ -37,10 +37,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||
->method('lang')
|
||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
||||
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
|
||||
$loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
|
||||
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/')
|
||||
|
@ -263,7 +263,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
self::$config['table_prefix'] . 'ext',
|
||||
dirname(__FILE__) . '/',
|
||||
$phpEx,
|
||||
$this->get_cache_driver()
|
||||
new \phpbb\cache\service($this->get_cache_driver(), $config, $this->db, $phpbb_root_path, $phpEx)
|
||||
);
|
||||
|
||||
return $extension_manager;
|
||||
|
@ -28,15 +28,12 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
|
||||
$this->version_helper = new \phpbb\version_helper(
|
||||
$this->cache,
|
||||
new \phpbb\config\config(array(
|
||||
'version' => '3.1.0',
|
||||
)),
|
||||
new \phpbb\file_downloader(),
|
||||
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
|
||||
new \phpbb\file_downloader()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,7 @@ class version_helper_remote_test extends \phpbb_test_case
|
||||
$this->version_helper = new \phpbb\version_helper(
|
||||
$this->cache,
|
||||
$config,
|
||||
$this->file_downloader,
|
||||
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
|
||||
$this->file_downloader
|
||||
);
|
||||
$this->user = new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime');
|
||||
$this->user->add_lang('acp/common');
|
||||
@ -161,8 +160,8 @@ class version_helper_remote_test extends \phpbb_test_case
|
||||
{
|
||||
try {
|
||||
$return = $this->version_helper->get_versions();
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->assertEquals((string)$e->getMessage(), $this->user->lang('VERSIONCHECK_FAIL'));
|
||||
} catch (\phpbb\exception\runtime_exception $e) {
|
||||
$this->assertEquals((string)$e->getMessage(), 'VERSIONCHECK_FAIL');
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -25,15 +25,12 @@ class phpbb_version_helper_test extends phpbb_test_case
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
|
||||
$this->version_helper = new \phpbb\version_helper(
|
||||
$this->cache,
|
||||
new \phpbb\config\config(array(
|
||||
'version' => '3.1.0',
|
||||
)),
|
||||
new \phpbb\file_downloader(),
|
||||
new \phpbb\user(new \phpbb\language\language($lang_loader), '\phpbb\datetime')
|
||||
new \phpbb\file_downloader()
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user