Skip to content

Commit

Permalink
[ticket/12610] Add command to check if the board is up to date.
Browse files Browse the repository at this point in the history
PHPBB3-12610
  • Loading branch information
Stephannos authored and Nicofuma committed Dec 3, 2016
1 parent 17e8726 commit 346f31a
Show file tree
Hide file tree
Showing 14 changed files with 491 additions and 72 deletions.
2 changes: 1 addition & 1 deletion phpBB/config/default/container/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ services:
- '%tables.ext%'
- '%core.root_path%'
- '%core.php_ext%'
- '@cache.driver'
- '@cache'

file_downloader:
class: phpbb\file_downloader
Expand Down
9 changes: 9 additions & 0 deletions phpBB/config/default/container/services_console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ services:
tags:
- { name: console.command }

console.command.update.check:
class: phpbb\console\command\update\check
arguments:
- @user
- @config
- @service_container
tags:
- { name: console.command }

console.command.user.activate:
class: phpbb\console\command\user\activate
arguments:
Expand Down
46 changes: 9 additions & 37 deletions phpBB/includes/acp/acp_extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function main()
// 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
{
Expand Down Expand Up @@ -303,11 +303,11 @@ function main()

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),
Expand Down Expand Up @@ -350,7 +350,7 @@ public function list_enabled_exts(\phpbb\extension\manager $phpbb_extension_mana

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
{
Expand All @@ -361,7 +361,7 @@ public function list_enabled_exts(\phpbb\extension\manager $phpbb_extension_mana
);

$force_update = $this->request->variable('versioncheck_force', false);
$updates = $this->version_check($md_manager, $force_update, !$force_update);
$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;
Expand Down Expand Up @@ -408,7 +408,7 @@ public function list_disabled_exts(\phpbb\extension\manager $phpbb_extension_man

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
{
Expand All @@ -419,7 +419,7 @@ public function list_disabled_exts(\phpbb\extension\manager $phpbb_extension_man
);

$force_update = $this->request->variable('versioncheck_force', false);
$updates = $this->version_check($md_manager, $force_update, !$force_update);
$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;
Expand Down Expand Up @@ -469,7 +469,7 @@ public function list_available_exts(\phpbb\extension\manager $phpbb_extension_ma

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
{
Expand All @@ -480,7 +480,7 @@ public function list_available_exts(\phpbb\extension\manager $phpbb_extension_ma
);

$force_update = $this->request->variable('versioncheck_force', false);
$updates = $this->version_check($md_manager, $force_update, !$force_update);
$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;
Expand Down Expand Up @@ -533,34 +533,6 @@ private function output_actions($block, $actions)
}
}

/**
* 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.
*/
Expand Down
4 changes: 4 additions & 0 deletions phpBB/language/en/acp/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@
'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',
));

Expand Down
29 changes: 20 additions & 9 deletions phpBB/language/en/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
'CLI_DESCRIPTION_CRON_LIST' => 'Prints a list of ready and unready cron jobs.',
'CLI_DESCRIPTION_CRON_RUN' => 'Runs all ready cron tasks.',
'CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1' => 'Name of the task to be run',
'CLI_DESCRIPTION_CRON_RUN_OPTION_CACHE' => 'Run check command with cache.',
'CLI_DESCRIPTION_CRON_RUN_OPTION_STABILITY' => 'Run command choosing to check only stable or unstable versions.',

'CLI_DESCRIPTION_DB_LIST' => 'List all installed and available migrations.',
'CLI_DESCRIPTION_DB_MIGRATE' => 'Updates the database by applying migrations.',
'CLI_DESCRIPTION_DB_REVERT' => 'Revert a migration.',
Expand All @@ -66,21 +69,29 @@
'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_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.',
Expand Down
Loading

0 comments on commit 346f31a

Please sign in to comment.