aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/assets/javascript/core.js21
-rw-r--r--phpBB/includes/acp/acp_board.php6
-rw-r--r--phpBB/includes/acp/acp_extensions.php131
-rw-r--r--phpBB/language/en/acp/board.php5
-rw-r--r--phpBB/phpbb/extension/manager.php32
-rw-r--r--phpBB/phpbb/extension/metadata_manager.php66
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php2
-rw-r--r--phpBB/phpbb/request/request.php6
-rw-r--r--phpBB/phpbb/version_helper.php63
-rw-r--r--phpBB/styles/prosilver/theme/forms.css2
-rw-r--r--phpBB/ucp.php25
-rw-r--r--phpBB/viewforum.php13
-rw-r--r--tests/mock/extension_manager.php2
-rw-r--r--tests/version/version_test.php292
14 files changed, 508 insertions, 158 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index f7ace80705..b079043396 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -33,21 +33,28 @@ phpbb.loadingIndicator = function() {
if (!$loadingIndicator.is(':visible')) {
$loadingIndicator.fadeIn(phpbb.alertTime);
- // Wait fifteen seconds and display an error if nothing has been returned by then.
+ // Wait 60 seconds and display an error if nothing has been returned by then.
phpbb.clearLoadingTimeout();
phpbbAlertTimer = setTimeout(function() {
- var $alert = $('#phpbb_alert');
-
- if ($loadingIndicator.is(':visible')) {
- phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req'));
- }
- }, 15000);
+ phpbb.showTimeoutMessage();
+ }, 60000);
}
return $loadingIndicator;
};
/**
+ * Show timeout message
+ */
+phpbb.showTimeoutMessage = function () {
+ var $alert = $('#phpbb_alert');
+
+ if ($loadingIndicator.is(':visible')) {
+ phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req'));
+ }
+};
+
+/**
* Clear loading alert timeout
*/
phpbb.clearLoadingTimeout = function() {
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index bcecb2f300..5c3c7f30aa 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -318,9 +318,9 @@ class acp_board
'title' => 'ACP_COOKIE_SETTINGS',
'vars' => array(
'legend1' => 'ACP_COOKIE_SETTINGS',
- 'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'validate' => 'string', 'type' => 'text::255', 'explain' => false),
- 'cookie_name' => array('lang' => 'COOKIE_NAME', 'validate' => 'string', 'type' => 'text::16', 'explain' => false),
- 'cookie_path' => array('lang' => 'COOKIE_PATH', 'validate' => 'string', 'type' => 'text::255', 'explain' => false),
+ 'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'validate' => 'string', 'type' => 'text::255', 'explain' => true),
+ 'cookie_name' => array('lang' => 'COOKIE_NAME', 'validate' => 'string', 'type' => 'text::16', 'explain' => true),
+ 'cookie_path' => array('lang' => 'COOKIE_PATH', 'validate' => 'string', 'type' => 'text::255', 'explain' => true),
'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'validate' => 'bool', 'type' => 'radio:disabled_enabled', 'explain' => true),
)
);
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index ef5f78d5bf..9e72ab83f8 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -22,21 +22,23 @@ if (!defined('IN_PHPBB'))
class acp_extensions
{
var $u_action;
+ var $tpl_name;
+ var $page_title;
- private $db;
private $config;
private $template;
private $user;
private $cache;
private $log;
private $request;
+ private $phpbb_dispatcher;
+ private $ext_manager;
function main()
{
// Start the page
- global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx, $phpbb_log, $cache, $phpbb_dispatcher;
+ global $config, $user, $template, $request, $phpbb_extension_manager, $phpbb_root_path, $phpEx, $phpbb_log, $cache, $phpbb_dispatcher;
- $this->db = $db;
$this->config = $config;
$this->template = $template;
$this->user = $user;
@@ -44,26 +46,27 @@ class acp_extensions
$this->request = $request;
$this->log = $phpbb_log;
$this->phpbb_dispatcher = $phpbb_dispatcher;
+ $this->ext_manager = $phpbb_extension_manager;
- $user->add_lang(array('install', 'acp/extensions', 'migrator'));
+ $this->user->add_lang(array('install', 'acp/extensions', 'migrator'));
$this->page_title = 'ACP_EXTENSIONS';
- $action = $request->variable('action', 'list');
- $ext_name = $request->variable('ext_name', '');
+ $action = $this->request->variable('action', 'list');
+ $ext_name = $this->request->variable('ext_name', '');
// What is a safe limit of execution time? Half the max execution time should be safe.
$safe_time_limit = (ini_get('max_execution_time') / 2);
$start_time = time();
// Cancel action
- if ($request->is_set_post('cancel'))
+ if ($this->request->is_set_post('cancel'))
{
$action = 'list';
$ext_name = '';
}
- if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($request->variable('hash', ''), $action . '.' . $ext_name))
+ if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($this->request->variable('hash', ''), $action . '.' . $ext_name))
{
trigger_error('FORM_INVALID', E_USER_WARNING);
}
@@ -93,7 +96,7 @@ 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, $user, $phpbb_root_path);
+ $md_manager = $this->ext_manager->create_extension_metadata_manager($ext_name, $this->template);
try
{
@@ -121,12 +124,12 @@ class acp_extensions
'force_unstable' => $force_unstable,
));
- confirm_box(false, $user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields);
+ confirm_box(false, $this->user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields);
}
else
{
- $config->set('extension_force_unstable', false);
- trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
+ $this->config->set('extension_force_unstable', false);
+ trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
break;
@@ -134,17 +137,17 @@ class acp_extensions
default:
if (confirm_box(true))
{
- $config->set('extension_force_unstable', true);
- trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
+ $this->config->set('extension_force_unstable', true);
+ trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
- $this->list_enabled_exts($phpbb_extension_manager);
- $this->list_disabled_exts($phpbb_extension_manager);
- $this->list_available_exts($phpbb_extension_manager);
+ $this->list_enabled_exts();
+ $this->list_disabled_exts();
+ $this->list_available_exts();
$this->template->assign_vars(array(
'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=list&versioncheck_force=1',
- 'FORCE_UNSTABLE' => $config['extension_force_unstable'],
+ 'FORCE_UNSTABLE' => $this->config['extension_force_unstable'],
'U_ACTION' => $this->u_action,
));
@@ -161,20 +164,20 @@ class acp_extensions
trigger_error($e . adm_back_link($this->u_action), E_USER_WARNING);
}
- $extension = $phpbb_extension_manager->get_extension($ext_name);
+ $extension = $this->ext_manager->get_extension($ext_name);
if (!$extension->is_enableable())
{
- trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- if ($phpbb_extension_manager->is_enabled($ext_name))
+ if ($this->ext_manager->is_enabled($ext_name))
{
redirect($this->u_action);
}
$this->tpl_name = 'acp_ext_enable';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'PRE' => true,
'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')),
'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name),
@@ -191,47 +194,47 @@ class acp_extensions
trigger_error($e . adm_back_link($this->u_action), E_USER_WARNING);
}
- $extension = $phpbb_extension_manager->get_extension($ext_name);
+ $extension = $this->ext_manager->get_extension($ext_name);
if (!$extension->is_enableable())
{
- trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
try
{
- while ($phpbb_extension_manager->enable_step($ext_name))
+ while ($this->ext_manager->enable_step($ext_name))
{
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
- $template->assign_var('S_NEXT_STEP', true);
+ $this->template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name));
}
}
- $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name));
+ $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name));
}
catch (\phpbb\db\migration\exception $e)
{
- $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
+ $this->template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($this->user));
}
$this->tpl_name = 'acp_ext_enable';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'U_RETURN' => $this->u_action . '&action=list',
));
break;
case 'disable_pre':
- if (!$phpbb_extension_manager->is_enabled($ext_name))
+ if (!$this->ext_manager->is_enabled($ext_name))
{
redirect($this->u_action);
}
$this->tpl_name = 'acp_ext_disable';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'PRE' => true,
'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DISABLE_CONFIRM', $md_manager->get_metadata('display-name')),
'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name),
@@ -239,38 +242,38 @@ class acp_extensions
break;
case 'disable':
- if (!$phpbb_extension_manager->is_enabled($ext_name))
+ if (!$this->ext_manager->is_enabled($ext_name))
{
redirect($this->u_action);
}
- while ($phpbb_extension_manager->disable_step($ext_name))
+ while ($this->ext_manager->disable_step($ext_name))
{
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
- $template->assign_var('S_NEXT_STEP', true);
+ $this->template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name));
}
}
- $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_DISABLE', time(), array($ext_name));
+ $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_DISABLE', time(), array($ext_name));
$this->tpl_name = 'acp_ext_disable';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'U_RETURN' => $this->u_action . '&action=list',
));
break;
case 'delete_data_pre':
- if ($phpbb_extension_manager->is_enabled($ext_name))
+ if ($this->ext_manager->is_enabled($ext_name))
{
redirect($this->u_action);
}
$this->tpl_name = 'acp_ext_delete_data';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'PRE' => true,
'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DELETE_DATA_CONFIRM', $md_manager->get_metadata('display-name')),
'U_PURGE' => $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name),
@@ -278,33 +281,33 @@ class acp_extensions
break;
case 'delete_data':
- if ($phpbb_extension_manager->is_enabled($ext_name))
+ if ($this->ext_manager->is_enabled($ext_name))
{
redirect($this->u_action);
}
try
{
- while ($phpbb_extension_manager->purge_step($ext_name))
+ while ($this->ext_manager->purge_step($ext_name))
{
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
- $template->assign_var('S_NEXT_STEP', true);
+ $this->template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name));
}
}
- $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_PURGE', time(), array($ext_name));
+ $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EXT_PURGE', time(), array($ext_name));
}
catch (\phpbb\db\migration\exception $e)
{
- $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
+ $this->template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($this->user));
}
$this->tpl_name = 'acp_ext_delete_data';
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'U_RETURN' => $this->u_action . '&action=list',
));
break;
@@ -315,28 +318,25 @@ class acp_extensions
try
{
- $updates_available = $this->version_check($md_manager, $request->variable('versioncheck_force', false));
+ $updates_available = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false));
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'S_UP_TO_DATE' => empty($updates_available),
'S_VERSIONCHECK' => true,
'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')),
));
- foreach ($updates_available as $branch => $version_data)
- {
- $template->assign_block_vars('updates_available', $version_data);
- }
+ $this->template->assign_block_vars('updates_available', $updates_available);
}
catch (\RuntimeException $e)
{
- $template->assign_vars(array(
+ $this->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() !== $this->user->lang('VERSIONCHECK_FAIL')) ? $e->getMessage() : '',
));
}
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'U_BACK' => $this->u_action . '&action=list',
'U_VERSIONCHECK_FORCE' => $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')),
));
@@ -370,16 +370,15 @@ class acp_extensions
/**
* Lists all the enabled extensions and dumps to the template
*
- * @param $phpbb_extension_manager An instance of the extension manager
* @return null
*/
- public function list_enabled_exts(\phpbb\extension\manager $phpbb_extension_manager)
+ public function list_enabled_exts()
{
$enabled_extension_meta_data = array();
- foreach ($phpbb_extension_manager->all_enabled() as $name => $location)
+ foreach ($this->ext_manager->all_enabled() as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $this->ext_manager->create_extension_metadata_manager($name, $this->template);
try
{
@@ -427,16 +426,15 @@ class acp_extensions
/**
* Lists all the disabled extensions and dumps to the template
*
- * @param $phpbb_extension_manager An instance of the extension manager
* @return null
*/
- public function list_disabled_exts(\phpbb\extension\manager $phpbb_extension_manager)
+ public function list_disabled_exts()
{
$disabled_extension_meta_data = array();
- foreach ($phpbb_extension_manager->all_disabled() as $name => $location)
+ foreach ($this->ext_manager->all_disabled() as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $this->ext_manager->create_extension_metadata_manager($name, $this->template);
try
{
@@ -485,18 +483,17 @@ class acp_extensions
/**
* Lists all the available extensions and dumps to the template
*
- * @param $phpbb_extension_manager An instance of the extension manager
* @return null
*/
- public function list_available_exts(\phpbb\extension\manager $phpbb_extension_manager)
+ public function list_available_exts()
{
- $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured());
+ $uninstalled = array_diff_key($this->ext_manager->all_available(), $this->ext_manager->all_configured());
$available_extension_meta_data = array();
foreach ($uninstalled as $name => $location)
{
- $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+ $md_manager = $this->ext_manager->create_extension_metadata_manager($name, $this->template);
try
{
@@ -565,7 +562,7 @@ class acp_extensions
* @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
+ * @return array
* @throws RuntimeException
*/
protected function version_check(\phpbb\extension\metadata_manager $md_manager, $force_update = false, $force_cache = false)
@@ -584,7 +581,7 @@ class acp_extensions
$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);
+ return $version_helper->get_ext_update_on_branch($force_update, $force_cache);
}
/**
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 8b5e113b16..1e77af14b1 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -345,11 +345,14 @@ $lang = array_merge($lang, array(
// Cookie Settings
$lang = array_merge($lang, array(
- 'ACP_COOKIE_SETTINGS_EXPLAIN' => 'These details define the data used to send cookies to your users browsers. In most cases the default values for the cookie settings should be sufficient. If you do need to change any do so with care, incorrect settings can prevent users logging in.',
+ 'ACP_COOKIE_SETTINGS_EXPLAIN' => 'These details define the data used to send cookies to your users browsers. In most cases the default values for the cookie settings should be sufficient. If you do need to change any do so with care, incorrect settings can prevent users logging in. If you have problems with users staying logging in to your board, visit the <b><a href="https://www.phpbb.com/support/go/cookie-settings/">phpBB.com Knowledge Base - Fixing incorrect cookie settings</a></b>.',
'COOKIE_DOMAIN' => 'Cookie domain',
+ 'COOKIE_DOMAIN_EXPLAIN' => 'In most cases the cookie domain is optional. Leave it blank if you are unsure.<br /><br /> In the case where you have a board integrated with other software or have multiple domains, then to determine the cookie domain you need to do the following. If you have something like <i>example.com</i> and <i>forums.example.com</i>, or perhaps <i>forums.example.com</i> and <i>blog.example.com</i>. Remove the subdomains until you find the common domain, <i>example.com</i>. Now add a dot in front of the common domain and you would enter .example.com (note the dot at the beginning).',
'COOKIE_NAME' => 'Cookie name',
+ 'COOKIE_NAME_EXPLAIN' => 'This can be anything what you want, make it original. Whenever the cookie settings are changed the name of the cookie should be changed.',
'COOKIE_PATH' => 'Cookie path',
+ 'COOKIE_PATH_EXPLAIN' => 'Note that this is always a slash, it does not matter what your board URL is.',
'COOKIE_SECURE' => 'Cookie secure',
'COOKIE_SECURE_EXPLAIN' => 'If your server is running via SSL set this to enabled else leave as disabled. Having this enabled and not running via SSL will result in server errors during redirects.',
'ONLINE_LENGTH' => 'View online time span',
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index 76f0e3558e..e7e5f83c23 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -149,10 +149,10 @@ 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
+ * @param \phpbb\template\template $template The template manager or null
* @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, \phpbb\template\template $template = null)
{
return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->user, $this->phpbb_root_path);
}
@@ -433,25 +433,11 @@ class manager
if ($file_info->isFile() && $file_info->getFilename() == 'composer.json')
{
$ext_name = $iterator->getInnerIterator()->getSubPath();
- $composer_file = $iterator->getPath() . '/composer.json';
-
- // Ignore the extension if there is no composer.json.
- if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file)))
- {
- continue;
- }
-
- $ext_info = json_decode($ext_info, true);
$ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name);
-
- // Ignore the extension if directory depth is not correct or if the directory structure
- // does not match the name value specified in composer.json.
- if (substr_count($ext_name, '/') !== 1 || !isset($ext_info['name']) || $ext_name != $ext_info['name'])
+ if ($this->is_available($ext_name))
{
- continue;
+ $available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
}
-
- $available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';
}
}
ksort($available);
@@ -524,7 +510,15 @@ class manager
*/
public function is_available($name)
{
- return file_exists($this->get_extension_path($name, true));
+ $md_manager = $this->create_extension_metadata_manager($name);
+ try
+ {
+ return $md_manager->get_metadata('all') && $md_manager->validate_enable();
+ }
+ catch (\phpbb\extension\exception $e)
+ {
+ return false;
+ }
}
/**
diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php
index 0842c5d7ae..a09f07bed2 100644
--- a/phpBB/phpbb/extension/metadata_manager.php
+++ b/phpBB/phpbb/extension/metadata_manager.php
@@ -66,17 +66,18 @@ class metadata_manager
*/
protected $metadata_file;
+ // @codingStandardsIgnoreStart
/**
* Creates the 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 \phpbb\template\template $template phpBB Template instance or null
* @param \phpbb\user $user User 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\user $user, $phpbb_root_path)
+ public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, \phpbb\template\template $template = null, \phpbb\user $user, $phpbb_root_path)
{
$this->config = $config;
$this->extension_manager = $extension_manager;
@@ -88,6 +89,7 @@ class metadata_manager
$this->metadata = array();
$this->metadata_file = '';
}
+ // @codingStandardsIgnoreEnd
/**
* Processes and gets the metadata requested
@@ -97,13 +99,11 @@ class metadata_manager
*/
public function get_metadata($element = 'all')
{
- $this->set_metadata_file();
-
- // Fetch the metadata
- $this->fetch_metadata();
-
- // Clean the metadata
- $this->clean_metadata_array();
+ // Fetch and clean the metadata if not done yet
+ if ($this->metadata_file === '')
+ {
+ $this->fetch_metadata_from_file();
+ }
switch ($element)
{
@@ -126,11 +126,11 @@ class metadata_manager
}
/**
- * Sets the filepath of the metadata file
+ * Sets the path of the metadata file, gets its contents and cleans loaded file
*
* @throws \phpbb\extension\exception
*/
- private function set_metadata_file()
+ private function fetch_metadata_from_file()
{
$ext_filepath = $this->extension_manager->get_extension_path($this->ext_name);
$metadata_filepath = $this->phpbb_root_path . $ext_filepath . 'composer.json';
@@ -141,37 +141,19 @@ class metadata_manager
{
throw new \phpbb\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file));
}
- }
- /**
- * Gets the contents of the composer.json file
- *
- * @return bool True if success, throws an exception on failure
- * @throws \phpbb\extension\exception
- */
- private function fetch_metadata()
- {
- if (!file_exists($this->metadata_file))
+ if (!($file_contents = file_get_contents($this->metadata_file)))
{
- throw new \phpbb\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file));
+ throw new \phpbb\extension\exception($this->user->lang('FILE_CONTENT_ERR', $this->metadata_file));
}
- else
- {
- if (!($file_contents = file_get_contents($this->metadata_file)))
- {
- throw new \phpbb\extension\exception($this->user->lang('FILE_CONTENT_ERR', $this->metadata_file));
- }
-
- if (($metadata = json_decode($file_contents, true)) === null)
- {
- throw new \phpbb\extension\exception($this->user->lang('FILE_JSON_DECODE_ERR', $this->metadata_file));
- }
- array_walk_recursive($metadata, array($this, 'sanitize_json'));
- $this->metadata = $metadata;
-
- return true;
+ if (($metadata = json_decode($file_contents, true)) === null)
+ {
+ throw new \phpbb\extension\exception($this->user->lang('FILE_JSON_DECODE_ERR', $this->metadata_file));
}
+
+ array_walk_recursive($metadata, array($this, 'sanitize_json'));
+ $this->metadata = $metadata;
}
/**
@@ -186,16 +168,6 @@ class metadata_manager
}
/**
- * This array handles the cleaning of the array
- *
- * @return array Contains the cleaned metadata array
- */
- private function clean_metadata_array()
- {
- return $this->metadata;
- }
-
- /**
* Validate fields
*
* @param string $name ("all" for display and enable validation
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index 90ac9a6703..63a0c79a3d 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -264,7 +264,7 @@ class type_date extends type_base
}
$profile_row['s_year_options'] = '<option value="0"' . ((!$year) ? ' selected="selected"' : '') . '>--</option>';
- for ($i = $now['year'] - 100; $i <= $now['year'] + 100; $i++)
+ for ($i = 1901; $i <= $now['year'] + 50; $i++)
{
$profile_row['s_year_options'] .= '<option value="' . $i . '"' . (($i == $year) ? ' selected="selected"' : '') . ">$i</option>";
}
diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php
index 4cac6fbaea..00ff9064cb 100644
--- a/phpBB/phpbb/request/request.php
+++ b/phpBB/phpbb/request/request.php
@@ -169,12 +169,6 @@ class request implements \phpbb\request\request_interface
$GLOBALS[$this->super_globals[$super_global]][$var_name] = $value;
}
}
-
- if (!$this->super_globals_disabled())
- {
- unset($GLOBALS[$this->super_globals[$super_global]][$var_name]);
- $GLOBALS[$this->super_globals[$super_global]][$var_name] = $value;
- }
}
/**
diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php
index b00f4f1d5f..9dc5a2e7c9 100644
--- a/phpBB/phpbb/version_helper.php
+++ b/phpBB/phpbb/version_helper.php
@@ -244,6 +244,69 @@ class version_helper
}
/**
+ * Gets the latest extension update for the current phpBB branch the user is on
+ * Will suggest versions from newer branches when EoL has been reached
+ * and/or version from newer branch is needed for having all known security
+ * issues fixed.
+ *
+ * @param bool $force_update Ignores cached data. Defaults to false.
+ * @param bool $force_cache Force the use of the cache. Override $force_update.
+ * @return array Version info or empty array if there are no updates
+ * @throws \RuntimeException
+ */
+ public function get_ext_update_on_branch($force_update = false, $force_cache = false)
+ {
+ $versions = $this->get_versions_matching_stability($force_update, $force_cache);
+
+ $self = $this;
+ $current_version = $this->current_version;
+
+ // Get current phpBB branch from version, e.g.: 3.2
+ preg_match('/^(\d+\.\d+).*$/', $this->config['version'], $matches);
+ $current_branch = $matches[1];
+
+ // Filter out any versions less than the current version
+ $versions = array_filter($versions, function($data) use ($self, $current_version) {
+ return $self->compare($data['current'], $current_version, '>=');
+ });
+
+ // Filter out any phpbb branches less than the current version
+ $branches = array_filter(array_keys($versions), function($branch) use ($self, $current_branch) {
+ return $self->compare($branch, $current_branch, '>=');
+ });
+ if (!empty($branches))
+ {
+ $versions = array_intersect_key($versions, array_flip($branches));
+ }
+ else
+ {
+ // If branches are empty, it means the current phpBB branch is newer than any branch the
+ // extension was validated against. Reverse sort the versions array so we get the newest
+ // validated release available.
+ krsort($versions);
+ }
+
+ // Get the first available version from the previous list.
+ $update_info = array_reduce($versions, function($value, $data) use ($self, $current_version) {
+ if ($value === null && $self->compare($data['current'], $current_version, '>='))
+ {
+ if (!$data['eol'] && (!$data['security'] || $self->compare($data['security'], $data['current'], '<=')))
+ {
+ return $self->compare($data['current'], $current_version, '>') ? $data : array();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ return $value;
+ });
+
+ return $update_info === null ? array() : $update_info;
+ }
+
+ /**
* Obtains the latest version information
*
* @param bool $force_update Ignores cached data. Defaults to false.
diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css
index 777f011c35..235c230ed4 100644
--- a/phpBB/styles/prosilver/theme/forms.css
+++ b/phpBB/styles/prosilver/theme/forms.css
@@ -288,7 +288,7 @@ textarea.inputbox {
}
input[type="number"] {
- -moz-padding-end: inherit;
+ -moz-padding-end: 0;
}
input[type="search"] {
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 8c74ca1f3c..5cd602bab5 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -237,6 +237,19 @@ switch ($mode)
add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']);
$message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
+
+ /**
+ * Event to run code after permissions are switched
+ *
+ * @event core.ucp_switch_permissions
+ * @var int user_id User ID to switch permission to
+ * @var array user_row User data
+ * @var string message Success message
+ * @since 3.1.11-RC1
+ */
+ $vars = array('user_id', 'user_row', 'message');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_switch_permissions', compact($vars)));
+
trigger_error($message);
break;
@@ -260,6 +273,18 @@ switch ($mode)
add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username);
$message = $user->lang['PERMISSIONS_RESTORED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
+
+ /**
+ * Event to run code after permissions are restored
+ *
+ * @event core.ucp_restore_permissions
+ * @var string username User name
+ * @var string message Success message
+ * @since 3.1.11-RC1
+ */
+ $vars = array('username', 'message');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_restore_permissions', compact($vars)));
+
trigger_error($message);
break;
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 1938c25fed..5c51975150 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -146,6 +146,13 @@ else
}
}
+// Is a forum specific topic count required?
+if ($forum_data['forum_topics_per_page'])
+{
+ $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
+}
+
+/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// Dump out the page header and load viewforum template
@@ -209,12 +216,6 @@ if ($mark_read == 'topics')
trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
}
-// Is a forum specific topic count required?
-if ($forum_data['forum_topics_per_page'])
-{
- $config['topics_per_page'] = $forum_data['forum_topics_per_page'];
-}
-
// Do the forum Prune thang - cron type job ...
if (!$config['use_system_cron'])
{
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 3b759fbbc2..94268159a8 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -20,5 +20,7 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->extensions = $extensions;
$this->filesystem = new \phpbb\filesystem();
$this->container = $container;
+ $this->config = new \phpbb\config\config(array());
+ $this->user = new \phpbb\user('\phpbb\datetime');
}
}
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index 54237f2059..0ed0fcb589 100644
--- a/tests/version/version_test.php
+++ b/tests/version/version_test.php
@@ -532,4 +532,296 @@ class phpbb_version_helper_test extends phpbb_test_case
$this->assertSame($expected, $version_helper->get_update_on_branch());
}
+
+ public function get_ext_update_on_branch_data()
+ {
+ return array(
+ // Single branch, check version for current branch
+ array(
+ '3.1.0',
+ '1.0.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(
+ '3.1.0',
+ '1.0.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(),
+ ),
+ array(
+ '3.2.0',
+ '1.0.0',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.2.0',
+ '1.1.1',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ // Single branch, check for newest version when branches don't match up
+ array(
+ '3.1.0',
+ '1.0.0',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.1.0',
+ '1.1.1',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ array(
+ '3.2.0',
+ '1.0.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(
+ '3.2.0',
+ '1.0.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(),
+ ),
+ array(
+ '3.3.0',
+ '1.0.0',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.3.0',
+ '1.1.1',
+ array(
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ // Multiple branches, check version for current branch
+ array(
+ '3.1.0',
+ '1.0.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.0.1',
+ ),
+ ),
+ array(
+ '3.1.0',
+ '1.0.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ array(
+ '3.1.0',
+ '1.1.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ array(
+ '3.2.0',
+ '1.0.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.2.0',
+ '1.0.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.2.0',
+ '1.1.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ // Multiple branches, check for newest version when branches don't match up
+ array(
+ '3.3.0',
+ '1.0.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.3.0',
+ '1.0.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.3.0',
+ '1.1.0',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(
+ '3.3.0',
+ '1.1.1',
+ array(
+ '3.1' => array(
+ 'current' => '1.0.1',
+ ),
+ '3.2' => array(
+ 'current' => '1.1.1',
+ ),
+ ),
+ array(),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider get_ext_update_on_branch_data
+ */
+ public function test_get_ext_update_on_branch($phpbb_version, $ext_version, $versions, $expected)
+ {
+ $version_helper = $this
+ ->getMockBuilder('\phpbb\version_helper')
+ ->setMethods(array(
+ 'get_versions_matching_stability',
+ ))
+ ->setConstructorArgs(array(
+ $this->cache,
+ new \phpbb\config\config(array(
+ 'version' => $phpbb_version,
+ )),
+ new \phpbb\file_downloader(),
+ new \phpbb\user('\phpbb\datetime'),
+ ))
+ ->getMock()
+ ;
+
+ $version_helper->expects($this->any())
+ ->method('get_versions_matching_stability')
+ ->will($this->returnValue($versions));
+
+ $version_helper->set_current_version($ext_version);
+
+ $this->assertSame($expected, $version_helper->get_ext_update_on_branch());
+ }
}