diff options
51 files changed, 645 insertions, 96 deletions
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index efdd6f1e22..7cf6c22236 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -840,6 +840,7 @@ table.zebra-table tbody tr:nth-child(odd) { } .row2 { + word-break: break-all; background-color: #DCEBFE; } diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index bd1925baf6..752dfa4ab2 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1332,7 +1332,6 @@ phpbb.toggleDropdown = function() { marginLeft: 0, left: 0, marginRight: 0, - right: 0, maxWidth: (windowWidth - 4) + 'px' }); diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index 3061fee817..5ae18334d9 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -71,9 +71,12 @@ require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); register_compatibility_globals(); +/** @var \phpbb\config\config $config */ +$config = $phpbb_container->get('config'); + /** @var \phpbb\language\language $language */ $language = $phpbb_container->get('language'); -$language->set_default_language($phpbb_container->get('config')['default_lang']); +$language->set_default_language($config['default_lang']); $language->add_lang(array('common', 'acp/common', 'cli')); /* @var $user \phpbb\user */ diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 8c3fb66a70..f9bb35791c 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -151,7 +151,7 @@ class acp_logs { $data = array(); - $checks = array('viewtopic', 'viewlogs', 'viewforum'); + $checks = array('viewpost', 'viewtopic', 'viewlogs', 'viewforum'); foreach ($checks as $check) { if (isset($row[$check]) && $row[$check]) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4aae84705b..cbea7afe6e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -66,23 +66,29 @@ function set_var(&$result, $var, $type, $multibyte = false) /** * Generates an alphanumeric random string of given length * +* @param int $num_chars Length of random string, defaults to 8. +* This number should be less or equal than 64. +* * @return string */ function gen_rand_string($num_chars = 8) { // [a, z] + [0, 9] = 36 - return substr(strtoupper(base_convert(unique_id(), 16, 36)), 0, $num_chars); + return substr(strtoupper(base_convert(bin2hex(random_bytes($num_chars + 1)), 16, 36)), 0, $num_chars); } /** * Generates a user-friendly alphanumeric random string of given length * We remove 0 and O so users cannot confuse those in passwords etc. * +* @param int $num_chars Length of random string, defaults to 8. +* This number should be less or equal than 64. +* * @return string */ function gen_rand_string_friendly($num_chars = 8) { - $rand_str = unique_id(); + $rand_str = bin2hex(random_bytes($num_chars + 1)); // Remove Z and Y from the base_convert(), replace 0 with Z and O with Y // [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34 @@ -2463,7 +2469,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $s_hidden_fields = build_hidden_fields($s_hidden_fields); - $template->assign_vars(array( + $login_box_template_data = array( 'LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, @@ -2471,6 +2477,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'U_RESEND_ACTIVATION' => ($config['require_activation'] == USER_ACTIVATION_SELF && $config['email_enable']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=resend_act') : '', 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), + 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), 'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, @@ -2480,7 +2487,29 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password', - )); + ); + + /** + * Event to add/modify login box template data + * + * @event core.login_box_modify_template_data + * @var int admin Flag whether user is admin + * @var string username User name + * @var int autologin Flag whether autologin is enabled + * @var string redirect Redirect URL + * @var array login_box_template_data Array with the login box template data + * @since 3.2.3-RC2 + */ + $vars = array( + 'admin', + 'username', + 'autologin', + 'redirect', + 'login_box_template_data', + ); + extract($phpbb_dispatcher->trigger_event('core.login_box_modify_template_data', compact($vars))); + + $template->assign_vars($login_box_template_data); page_header($user->lang['LOGIN']); @@ -4401,9 +4430,10 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), 'U_CONTACT_US' => ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', - 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), + 'U_TEAM' => (!$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), + 'UA_PRIVACY' => addslashes(append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy')), 'U_RESTORE_PERMISSIONS' => ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=restore_perm') : '', 'U_FEED' => $controller_helper->route('phpbb_feed_index'), diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 2e0a1cf9e6..4f1f9bb990 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -501,6 +501,29 @@ class mcp_queue AND t.topic_id = p.topic_id AND u.user_id = p.poster_id ORDER BY ' . $sort_order_sql; + + /** + * Alter sql query to get information on all posts in queue + * + * @event core.mcp_queue_get_posts_for_posts_query_before + * @var string sql String with the query to be executed + * @var array forum_list List of forums that contain the posts + * @var int visibility_const Integer with one of the possible ITEM_* constant values + * @var int topic_id topic_id in the page request + * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) + * @var string sort_order_sql String with the ORDER BY SQL code used in this query + * @since 3.2.3-RC2 + */ + $vars = array( + 'sql', + 'forum_list', + 'visibility_const', + 'topic_id', + 'limit_time_sql', + 'sort_order_sql', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_posts_query_before', compact($vars))); + $result = $db->sql_query($sql); $post_data = $rowset = array(); @@ -588,7 +611,7 @@ class mcp_queue $row['post_username'] = $row['username'] ?: $user->lang['GUEST']; } - $template->assign_block_vars('postrow', array( + $post_row = array( 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''), @@ -606,7 +629,25 @@ class mcp_queue 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time']), 'S_HAS_ATTACHMENTS' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'], - )); + ); + + /** + * Alter sql query to get information on all topics in the list of forums provided. + * + * @event core.mcp_queue_get_posts_modify_post_row + * @var array post_row Template variables for current post + * @var array row Post data + * @var array forum_names Forum names + * @since 3.2.3-RC2 + */ + $vars = array( + 'post_row', + 'row', + 'forum_names', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_modify_post_row', compact($vars))); + + $template->assign_block_vars('postrow', $post_row); } unset($rowset, $forum_names); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index beb440ce76..a36bf619f8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -159,7 +159,7 @@ class ucp_profile $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( 'reportee_id' => $user->data['user_id'], $user->data['username'], - $data['user_email'], + $user->data['user_email'], $data['email'] )); } diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 25b656499c..76982be098 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -348,7 +348,7 @@ $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. 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>.', + '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 <strong><a href="https://www.phpbb.com/support/go/cookie-settings">phpBB.com Knowledge Base - Fixing incorrect cookie settings</a></strong>.', '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).', @@ -404,10 +404,10 @@ $lang = array_merge($lang, array( 'READ_NOTIFICATION_EXPIRE_DAYS_EXPLAIN' => 'Number of days that will elapse before a read notification will automatically be deleted. Set this value to 0 to make notifications permanent.', 'RECOMPILE_STYLES' => 'Recompile stale style components', 'RECOMPILE_STYLES_EXPLAIN' => 'Check for updated style components on filesystem and recompile.', + 'YES_ACCURATE_PM_BUTTON' => 'Enable permission specific PM button in topic pages', + 'YES_ACCURATE_PM_BUTTON_EXPLAIN' => 'If this setting is enabled, only post profiles of users who are permitted to read private messages will have a private message button.', 'YES_ANON_READ_MARKING' => 'Enable topic marking for guests', 'YES_ANON_READ_MARKING_EXPLAIN' => 'Stores read/unread status information for guests. If disabled, posts are always marked read for guests.', - 'YES_ACCURATE_PM_BUTTON' => 'Enable accurate PM indicator in topic pages', - 'YES_ACCURATE_PM_BUTTON_EXPLAIN' => 'If this setting is enabled, only users who are permitted to read private messages will have a private message button.', 'YES_BIRTHDAYS' => 'Enable birthday listing', 'YES_BIRTHDAYS_EXPLAIN' => 'If disabled the birthday listing is no longer displayed. To let this setting take effect the birthday feature needs to be enabled too.', 'YES_JUMPBOX' => 'Enable display of jumpbox', diff --git a/phpBB/language/en/acp/groups.php b/phpBB/language/en/acp/groups.php index 9d0bb5f8b9..c3a5ae9e44 100644 --- a/phpBB/language/en/acp/groups.php +++ b/phpBB/language/en/acp/groups.php @@ -92,7 +92,7 @@ $lang = array_merge($lang, array( 'GROUP_OPEN' => 'Open', 'GROUP_PENDING' => 'Pending members', 'GROUP_MAX_RECIPIENTS' => 'Maximum number of allowed recipients per private message', - 'GROUP_MAX_RECIPIENTS_EXPLAIN' => 'The maximum number of allowed recipients in a private message. The maximum for all groups of the user is used to determine the actual value.<br />Set this value to 0 to overwrite the setting for all users of this group with the board-wide setting.', + 'GROUP_MAX_RECIPIENTS_EXPLAIN' => 'The maximum number of allowed recipients in a private message. The maximum for all groups of the user is used to determine the actual value.<br />Set this value to 0 to overwrite the setting for all users of this group with the board-wide setting.', 'GROUP_OPTIONS_SAVE' => 'Group wide options', 'GROUP_PROMOTE' => 'Promote to group leader', 'GROUP_RANK' => 'Group rank', diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php index d365aeb183..41cbd9cb93 100644 --- a/phpBB/language/en/acp/profile.php +++ b/phpBB/language/en/acp/profile.php @@ -161,8 +161,8 @@ $lang = array_merge($lang, array( 'STEP_2_EXPLAIN_EDIT' => 'Here you are able to change some common options.<br /><strong>Please note that changes to profile fields will not affect existing profile fields entered by your users.</strong>', 'STEP_2_TITLE_CREATE' => 'Profile type specific options', 'STEP_2_TITLE_EDIT' => 'Profile type specific options', - 'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. The profile field will work with the default language enabled, you are able to fill out the remaining language items later too.', - 'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. The profile field will work with the default language enabled.', + 'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. If you don’t, then default language setting for this custom profile field will be used, you are able to fill out the remaining language items later too.', + 'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. If you don’t, then default language setting for this custom profile field will be used.', 'STEP_3_TITLE_CREATE' => 'Remaining language definitions', 'STEP_3_TITLE_EDIT' => 'Language definitions', 'STRING_DEFAULT_VALUE_EXPLAIN' => 'Enter a default phrase to be displayed, a default value. Leave empty if you want to show it empty at the first place.', diff --git a/phpBB/language/en/captcha_recaptcha.php b/phpBB/language/en/captcha_recaptcha.php index 0acf850043..dde2a4ba08 100644 --- a/phpBB/language/en/captcha_recaptcha.php +++ b/phpBB/language/en/captcha_recaptcha.php @@ -37,7 +37,7 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( - 'RECAPTCHA_LANG' => 'en', + 'RECAPTCHA_LANG' => 'en-GB', // Find the language/country code on https://developers.google.com/recaptcha/docs/language - If no code exists for your language you can use "en" or leave the string empty 'RECAPTCHA_NOT_AVAILABLE' => 'In order to use reCaptcha, you must create an account on <a href="http://www.google.com/recaptcha">www.google.com/recaptcha</a>.', 'CAPTCHA_RECAPTCHA' => 'reCaptcha', 'RECAPTCHA_INCORRECT' => 'The solution you provided was incorrect', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 5140919dad..213563aea0 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -193,7 +193,7 @@ $lang = array_merge($lang, array( 'DAYS' => 'Days', 'DELETE' => 'Delete', 'DELETE_ALL' => 'Delete all', - 'DELETE_COOKIES' => 'Delete all board cookies', + 'DELETE_COOKIES' => 'Delete cookies', 'DELETE_MARKED' => 'Delete marked', 'DELETE_POST' => 'Delete post', 'DELIMITER' => 'Delimiter', @@ -608,6 +608,7 @@ $lang = array_merge($lang, array( 'PREVIOUS' => 'Previous', // Used in pagination 'PREVIOUS_STEP' => 'Previous', 'PRIVACY' => 'Privacy policy', + 'PRIVACY_LINK' => 'Privacy', 'PRIVATE_MESSAGE' => 'Private message', 'PRIVATE_MESSAGES' => 'Private messages', 'PRIVATE_MESSAGING' => 'Private messaging', @@ -732,6 +733,7 @@ $lang = array_merge($lang, array( 'SUBMIT' => 'Submit', 'TB' => 'TB', + 'TERMS_LINK' => 'Terms', 'TERMS_USE' => 'Terms of use', 'TEST_CONNECTION' => 'Test connection', 'THE_TEAM' => 'The team', diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt index b9416d8e40..12e0bb8393 100644 --- a/phpBB/language/en/email/newtopic_notify.txt +++ b/phpBB/language/en/email/newtopic_notify.txt @@ -6,6 +6,10 @@ You are receiving this notification because you are watching the forum "{FORUM_N {U_FORUM} +To see new topic directly, visit the following link: + +{U_TOPIC} + If you no longer wish to watch this forum you can either click the "Unsubscribe forum" link found in the forum above, or by clicking the following link: {U_STOP_WATCHING_FORUM} diff --git a/phpBB/language/en/help/faq.php b/phpBB/language/en/help/faq.php index e59d950948..6b165da0f8 100644 --- a/phpBB/language/en/help/faq.php +++ b/phpBB/language/en/help/faq.php @@ -111,8 +111,8 @@ $lang = array_merge($lang, array( 'HELP_FAQ_LOGIN_CANNOT_REGISTER_QUESTION' => 'Why can’t I register?', 'HELP_FAQ_LOGIN_COPPA_ANSWER' => 'COPPA, or the Children’s Online Privacy Protection Act of 1998, is a law in the United States requiring websites which can potentially collect information from minors under the age of 13 to have written parental consent or some other method of legal guardian acknowledgment, allowing the collection of personally identifiable information from a minor under the age of 13. If you are unsure if this applies to you as someone trying to register or to the website you are trying to register on, contact legal counsel for assistance. Please note that phpBB Limited and the owners of this board cannot provide legal advice and is not a point of contact for legal concerns of any kind, except as outlined in question “Who do I contact about abusive and/or legal matters related to this board?”.', 'HELP_FAQ_LOGIN_COPPA_QUESTION' => 'What is COPPA?', - 'HELP_FAQ_LOGIN_DELETE_COOKIES_ANSWER' => '“Delete all board cookies” deletes the cookies created by phpBB which keep you authenticated and logged into the board. Cookies also provide functions such as read tracking if they have been enabled by a board administrator. If you are having login or logout problems, deleting board cookies may help.', - 'HELP_FAQ_LOGIN_DELETE_COOKIES_QUESTION' => 'What does the “Delete all board cookies” do?', + 'HELP_FAQ_LOGIN_DELETE_COOKIES_ANSWER' => '“Delete cookies” deletes the cookies created by phpBB which keep you authenticated and logged into the board. Cookies also provide functions such as read tracking if they have been enabled by a board administrator. If you are having login or logout problems, deleting board cookies may help.', + 'HELP_FAQ_LOGIN_DELETE_COOKIES_QUESTION' => 'What does the “Delete cookies” do?', 'HELP_FAQ_LOGIN_LOST_PASSWORD_ANSWER' => 'Don’t panic! While your password cannot be retrieved, it can easily be reset. Visit the login page and click <em>I forgot my password</em>. Follow the instructions and you should be able to log in again shortly.<br />However, if you are not able to reset your password, contact a board administrator.', 'HELP_FAQ_LOGIN_LOST_PASSWORD_QUESTION' => 'I’ve lost my password!', 'HELP_FAQ_LOGIN_REGISTER_ANSWER' => 'You may not have to, it is up to the administrator of the board as to whether you need to register in order to post messages. However; registration will give you access to additional features not available to guest users such as definable avatar images, private messaging, emailing of fellow users, usergroup subscription, etc. It only takes a few moments to register so it is recommended you do so.', diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index 8b773017c5..4b84e4201c 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -158,7 +158,7 @@ class local extends \phpbb\avatar\driver\driver */ protected function get_avatar_list($user) { - $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list'); + $avatar_list = ($this->cache == null) ? false : $this->cache->get('_avatar_local_list_' . $user->data['user_lang']); if ($avatar_list === false) { @@ -198,7 +198,7 @@ class local extends \phpbb\avatar\driver\driver if ($this->cache != null) { - $this->cache->put('_avatar_local_list', $avatar_list, 86400); + $this->cache->put('_avatar_local_list_' . $user->data['user_lang'], $avatar_list, 86400); } } diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php index a52067f484..804adc4490 100644 --- a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php +++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php @@ -32,10 +32,7 @@ class add_help_phpbb extends \phpbb\db\migration\migration return array( array('config.add', array('help_send_statistics', true)), array('config.add', array('help_send_statistics_time', 0)), - array('if', array( - array('module.exists', array('acp', false, 'ACP_SEND_STATISTICS')), - array('module.remove', array('acp', false, 'ACP_SEND_STATISTICS')), - )), + array('module.remove', array('acp', false, 'ACP_SEND_STATISTICS')), array('module.add', array( 'acp', 'ACP_SERVER_CONFIGURATION', diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index e24c78e228..3893935723 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -519,12 +519,6 @@ class module implements \phpbb\db\migration\tool\tool_interface // Allow '' to be sent as 0 $parent_id = $parent_id ?: 0; - // If automatic adding is in action, convert array back to string to simplify things - if (is_array($data) && count($data) == 1) - { - $data = $data['module_langname']; - } - if (!is_numeric($parent_id)) { // Refresh the $module_categories array diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index a425df56e8..2b0c66fc58 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -760,7 +760,7 @@ class migrator $condition = $parameters[0]; - if (!$condition) + if (!$condition || (is_array($condition) && !$this->run_step($condition, $last_result, $reverse))) { return false; } diff --git a/phpBB/phpbb/debug/error_handler.php b/phpBB/phpbb/debug/error_handler.php index 246e724f56..ebd828b97f 100644 --- a/phpBB/phpbb/debug/error_handler.php +++ b/phpBB/phpbb/debug/error_handler.php @@ -17,7 +17,7 @@ use Symfony\Component\Debug\ErrorHandler; class error_handler extends ErrorHandler { - public function handleError($type, $message, $file, $line, array $context, array $backtrace = null) + public function handleError($type, $message, $file, $line) { if ($type === E_USER_WARNING || $type === E_USER_NOTICE) { @@ -26,6 +26,6 @@ class error_handler extends ErrorHandler $handler($type, $message, $file, $line); } - return parent::handleError($type, $message, $file, $line, $context, $backtrace); + return parent::handleError($type, $message, $file, $line); } } diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index ac1a1a1733..8c1ce8bde2 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -143,6 +143,13 @@ class container_builder { if ($this->use_extensions) { + $autoload_cache = new ConfigCache($this->get_autoload_filename(), defined('DEBUG')); + if (!$autoload_cache->isFresh()) + { + // autoload cache should be refreshed + $this->load_extensions(); + } + require($this->get_autoload_filename()); } diff --git a/phpBB/phpbb/event/php_exporter.php b/phpBB/phpbb/event/php_exporter.php index 64d1e429b7..71c94a681d 100644 --- a/phpBB/phpbb/event/php_exporter.php +++ b/phpBB/phpbb/event/php_exporter.php @@ -264,7 +264,30 @@ class php_exporter // Find event description line $description_line_num = $this->find_description(); - $description = substr(trim($this->file_lines[$description_line_num]), strlen('* ')); + $description_lines = array(); + + while (true) + { + $description_line = substr(trim($this->file_lines[$description_line_num]), strlen('*')); + $description_line = trim(str_replace("\t", " ", $description_line)); + + // Reached end of description if line is a tag + if (strlen($description_line) && $description_line[0] == '@') + { + break; + } + + $description_lines[] = $description_line; + $description_line_num++; + } + + // If there is an empty line between description and first tag, remove it + if (!strlen(end($description_lines))) + { + array_pop($description_lines); + } + + $description = trim(implode('<br/>', $description_lines)); if (isset($this->events[$this->current_event])) { diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 3f39448f05..bfafdf5ddd 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -367,7 +367,7 @@ class filesystem implements filesystem_interface $common_php_group = @filegroup(__FILE__); // And the owner and the groups PHP is running under. - $php_uid = (function_exists('posic_getuid')) ? @posix_getuid() : false; + $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; // If we are unable to get owner/group, then do not try to set them by guessing diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index de9345ca85..80934dc411 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1614,13 +1614,15 @@ class session return; } + // Do not update the session page for ajax requests, so the view online still works as intended + $page_changed = $this->update_session_page && $this->data['session_page'] != $this->page['page'] && !$request->is_ajax(); + // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - ((isset($this->data['session_time'])) ? $this->data['session_time'] : 0) > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) + if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed) { $sql_ary = array('session_time' => $this->time_now); - // Do not update the session page for ajax requests, so the view online still works as intended - if ($this->update_session_page && !$request->is_ajax()) + if ($page_changed) { $sql_ary['session_page'] = substr($this->page['page'], 0, 199); $sql_ary['session_forum_id'] = $this->page['forum']; diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php index de583d3224..2ba6d185ad 100644 --- a/phpBB/phpbb/template/context.php +++ b/phpBB/phpbb/template/context.php @@ -274,6 +274,11 @@ class context { $name = substr($blocks[$i], 0, $pos); + if (empty($block[$name])) + { + return array(); + } + if (strpos($blocks[$i], '[]') === $pos) { $index = count($block[$name]) - 1; @@ -286,6 +291,11 @@ class context else { $name = $blocks[$i]; + if (empty($block[$name])) + { + return array(); + } + $index = count($block[$name]) - 1; } $block = $block[$name]; diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index 1aa7717470..f6f8e03ca2 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -172,7 +172,7 @@ class extension extends \Twig_Extension $context_vars = $this->context->get_root_ref(); - if (isset($context_vars['L_' . $key])) + if (is_string($key) && isset($context_vars['L_' . $key])) { return $context_vars['L_' . $key]; } diff --git a/phpBB/styles/prosilver/template/mcp_ban.html b/phpBB/styles/prosilver/template/mcp_ban.html index 5b798d9b6c..f6e4620ad8 100644 --- a/phpBB/styles/prosilver/template/mcp_ban.html +++ b/phpBB/styles/prosilver/template/mcp_ban.html @@ -1,8 +1,6 @@ <!-- INCLUDE mcp_header.html --> -<script type="text/javascript"> -// <![CDATA[ - +<script> var ban_length = new Array(); ban_length[-1] = ''; var ban_reason = new Array(); @@ -34,8 +32,6 @@ document.getElementById('unbangivereason').innerHTML = ''; } } - -// ]]> </script> <form id="mcp_ban" method="post" action="{U_ACTION}"> diff --git a/phpBB/styles/prosilver/template/navbar_header.html b/phpBB/styles/prosilver/template/navbar_header.html index b8080a6be3..2d33849cf0 100644 --- a/phpBB/styles/prosilver/template/navbar_header.html +++ b/phpBB/styles/prosilver/template/navbar_header.html @@ -123,11 +123,13 @@ <i class="icon fa-sliders fa-fw" aria-hidden="true"></i><span>{L_PROFILE}</span> </a> </li> - <li> - <a href="{U_USER_PROFILE}" title="{L_READ_PROFILE}" role="menuitem"> - <i class="icon fa-user fa-fw" aria-hidden="true"></i><span>{L_READ_PROFILE}</span> - </a> - </li> + <!-- IF U_USER_PROFILE --> + <li> + <a href="{U_USER_PROFILE}" title="{L_READ_PROFILE}" role="menuitem"> + <i class="icon fa-user fa-fw" aria-hidden="true"></i><span>{L_READ_PROFILE}</span> + </a> + </li> + <!-- ENDIF --> <!-- EVENT navbar_header_profile_list_after --> diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index b01b0bb213..5bad7baeb1 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -8,11 +8,34 @@ <div class="copyright"> <!-- EVENT overall_footer_copyright_prepend --> - {CREDIT_LINE} - <!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF --> + <p class="footer-row"> + <span class="footer-copyright">{{ CREDIT_LINE }}</span> + </p> + <!-- IF TRANSLATION_INFO --> + <p class="footer-row"> + <span class="footer-copyright">{{ TRANSLATION_INFO }}</span> + </p> + <!-- ENDIF --> <!-- EVENT overall_footer_copyright_append --> - <!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF --> - <!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF --> + <p class="footer-row"> + <a class="footer-link" href="{{ U_PRIVACY }}" title="{{ lang('PRIVACY_LINK') }}" role="menuitem"> + <span class="footer-link-text">Privacy</span> + </a> + | + <a class="footer-link" href="{{ U_TERMS_USE }}" title="{{ lang('TERMS_LINK') }}" role="menuitem"> + <span class="footer-link-text">Terms</span> + </a> + </p> + <!-- IF DEBUG_OUTPUT --> + <p class="footer-row"> + <span class="footer-info">{{ DEBUG_OUTPUT }}</span> + </p> + <!-- ENDIF --> + <!-- IF U_ACP --> + <p class="footer-row"> + <a class="footer-link text-strong" href="{{ U_ACP }}">{{ lang('ACP') }}</a> + </p> + <!-- ENDIF --> </div> <div id="darkenwrapper" class="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}" data-ajax-error-text-abort="{L_AJAX_ERROR_TEXT_ABORT}" data-ajax-error-text-timeout="{L_AJAX_ERROR_TEXT_TIMEOUT}" data-ajax-error-text-parsererror="{L_AJAX_ERROR_TEXT_PARSERERROR}"> @@ -40,13 +63,13 @@ <!-- IF not S_IS_BOT -->{RUN_CRON_TASK}<!-- ENDIF --> </div> -<script type="text/javascript" src="{T_JQUERY_LINK}"></script> -<!-- IF S_ALLOW_CDN --><script type="text/javascript">window.jQuery || document.write('\x3Cscript src="{T_ASSETS_PATH}/javascript/jquery.min.js?assets_version={T_ASSETS_VERSION}">\x3C/script>');</script><!-- ENDIF --> -<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script> +<script src="{T_JQUERY_LINK}"></script> +<!-- IF S_ALLOW_CDN --><script>window.jQuery || document.write('\x3Cscript src="{T_ASSETS_PATH}/javascript/jquery.min.js?assets_version={T_ASSETS_VERSION}">\x3C/script>');</script><!-- ENDIF --> +<script src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script> <!-- INCLUDEJS forum_fn.js --> <!-- INCLUDEJS ajax.js --> <!-- IF S_ALLOW_CDN --> - <script type="text/javascript"> + <script> (function($){ var $fa_cdn = $('head').find('link[rel="stylesheet"]').first(), $span = $('<span class="fa" style="display:none"></span>').appendTo('body'); @@ -78,7 +101,7 @@ "message": "{LA_COOKIE_CONSENT_MSG}", "dismiss": "{LA_COOKIE_CONSENT_OK}", "link": "{LA_COOKIE_CONSENT_INFO}", - "href": "{LA_COOKIE_CONSENT_HREF}" + "href": "{UA_PRIVACY}" } }); }); diff --git a/phpBB/styles/prosilver/template/plupload.html b/phpBB/styles/prosilver/template/plupload.html index fc663118c1..1eb84372e8 100644 --- a/phpBB/styles/prosilver/template/plupload.html +++ b/phpBB/styles/prosilver/template/plupload.html @@ -1,5 +1,4 @@ -<script type="text/javascript"> -//<![CDATA[ +<script> phpbb.plupload = { i18n: { 'b': '{LA_BYTES_SHORT}', @@ -63,7 +62,6 @@ phpbb.plupload = { maxFiles: {MAX_ATTACHMENTS}, data: {S_ATTACH_DATA}, } -//]]> </script> <!-- INCLUDEJS {T_ASSETS_PATH}/plupload/plupload.full.min.js --> <!-- INCLUDEJS {T_ASSETS_PATH}/javascript/plupload.js --> diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index 14185ed66b..122afdf978 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -1,6 +1,5 @@ -<script type="text/javascript"> -// <![CDATA[ +<script> var form_name = 'postform'; var text_name = <!-- IF $SIG_EDIT -->'signature'<!-- ELSE -->'message'<!-- ENDIF -->; var load_draft = false; @@ -46,8 +45,6 @@ document.getElementById('bbpalette').value = '{LA_FONT_COLOR}'; } } - -// ]]> </script> <!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --> diff --git a/phpBB/styles/prosilver/template/posting_smilies.html b/phpBB/styles/prosilver/template/posting_smilies.html index 54e82a58bc..b5794d5aff 100644 --- a/phpBB/styles/prosilver/template/posting_smilies.html +++ b/phpBB/styles/prosilver/template/posting_smilies.html @@ -1,10 +1,8 @@ <!-- INCLUDE simple_header.html --> -<script type="text/javascript"> -// <![CDATA[ +<script> var form_name = opener.form_name; var text_name = opener.text_name; -// ]]> </script> <!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --> diff --git a/phpBB/styles/prosilver/template/posting_topic_review.html b/phpBB/styles/prosilver/template/posting_topic_review.html index 857c686774..55739070ae 100644 --- a/phpBB/styles/prosilver/template/posting_topic_review.html +++ b/phpBB/styles/prosilver/template/posting_topic_review.html @@ -5,10 +5,8 @@ </h3> <div id="topicreview" class="topicreview"> -<script type="text/javascript"> -// <![CDATA[ +<script> bbcodeEnabled = {S_BBCODE_ALLOWED}; -// ]]> </script> <!-- BEGIN topic_review_row --> diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 614c137835..907ddd97ba 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -24,9 +24,9 @@ </div> </div> -<script type="text/javascript" src="{T_JQUERY_LINK}"></script> -<!-- IF S_ALLOW_CDN --><script type="text/javascript">window.jQuery || document.write('\x3Cscript src="{T_ASSETS_PATH}/javascript/jquery.min.js?assets_version={T_ASSETS_VERSION}">\x3C/script>');</script><!-- ENDIF --> -<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script> +<script src="{T_JQUERY_LINK}"></script> +<!-- IF S_ALLOW_CDN --><script>window.jQuery || document.write('\x3Cscript src="{T_ASSETS_PATH}/javascript/jquery.min.js?assets_version={T_ASSETS_VERSION}">\x3C/script>');</script><!-- ENDIF --> +<script src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script> <!-- INCLUDEJS forum_fn.js --> <!-- INCLUDEJS ajax.js --> diff --git a/phpBB/styles/prosilver/template/ucp_agreement.html b/phpBB/styles/prosilver/template/ucp_agreement.html index 943774c6ec..ace65254d7 100644 --- a/phpBB/styles/prosilver/template/ucp_agreement.html +++ b/phpBB/styles/prosilver/template/ucp_agreement.html @@ -3,8 +3,7 @@ <!-- IF S_SHOW_COPPA or S_REGISTRATION --> <!-- IF S_LANG_OPTIONS --> -<script type="text/javascript"> -// <![CDATA[ +<script> /** * Change language */ @@ -14,8 +13,6 @@ document.forms['register'].change_lang.value = lang_iso; document.forms['register'].submit(); } - -// ]]> </script> <form method="post" action="{S_UCP_ACTION}" id="register"> diff --git a/phpBB/styles/prosilver/template/ucp_pm_history.html b/phpBB/styles/prosilver/template/ucp_pm_history.html index e97befc552..6362a0b824 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_history.html +++ b/phpBB/styles/prosilver/template/ucp_pm_history.html @@ -6,10 +6,8 @@ <!-- EVENT ucp_pm_history_review_before --> <div id="topicreview" class="topicreview"> - <script type="text/javascript"> - // <![CDATA[ + <script> bbcodeEnabled = {S_BBCODE_ALLOWED}; - // ]]> </script> <!-- BEGIN history_row --> <div class="post <!-- IF history_row.S_ROW_COUNT is even -->bg1<!-- ELSE -->bg2<!-- ENDIF -->"> diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 4cd9f6655b..1650705d4b 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -85,8 +85,7 @@ </fieldset> </form> -<script type="text/javascript"> -// <![CDATA[ +<script> var date_format = '{A_DATE_FORMAT}'; var default_dateformat = '{A_DEFAULT_DATEFORMAT}'; @@ -118,7 +117,6 @@ } window.onload = customDates; -// ]]> </script> <!-- INCLUDE ucp_footer.html --> diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html index 38413addba..bf39990c35 100644 --- a/phpBB/styles/prosilver/template/ucp_register.html +++ b/phpBB/styles/prosilver/template/ucp_register.html @@ -1,7 +1,6 @@ <!-- INCLUDE overall_header.html --> -<script type="text/javascript"> -// <![CDATA[ +<script> /** * Change language */ @@ -11,7 +10,6 @@ document.forms['register'].change_lang.value = lang_iso; document.forms['register'].submit.click(); } -// ]]> </script> <form id="register" method="post" action="{S_UCP_ACTION}"{S_FORM_ENCTYPE}> diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 348355e8c4..a0dc5e043b 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -981,8 +981,15 @@ fieldset.fields1 dl.pmlist dd.recipients { /* Miscellaneous styles ---------------------------------------- */ .copyright { - padding: 5px; + font-size: 10px; text-align: center; + padding: 10px; +} + +.footer-row { + font-size: 10px; + line-height: 1.8; + margin: 0; } .small { @@ -1267,6 +1274,10 @@ ul.linklist:after, width: 50px; } +.dropdown .clone.hidden { + display: none; +} + .dropdown .clone.hidden + li.separator { display: none; } diff --git a/phpBB/styles/prosilver/theme/responsive.css b/phpBB/styles/prosilver/theme/responsive.css index fcc11f1fc2..ca4054c27f 100644 --- a/phpBB/styles/prosilver/theme/responsive.css +++ b/phpBB/styles/prosilver/theme/responsive.css @@ -421,6 +421,7 @@ .column1, .column2, .left-box.profile-details { float: none; width: auto; + clear: both; } /* Polls diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 04a39e83d5..416ffe3d90 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -506,7 +506,7 @@ if ($forum_data['forum_type'] == FORUM_POST) 'WHERE' => '(t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_ANNOUNCE . ') OR - (' . $db->sql_in_set('t.forum_id', $g_forum_ary) . ' + (' . $db->sql_in_set('t.forum_id', $g_forum_ary, false, true) . ' AND t.topic_type = ' . POST_GLOBAL . ')', 'ORDER_BY' => 't.topic_time DESC', diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_info.php b/tests/dbal/ext/foo/bar/acp/acp_test_info.php new file mode 100644 index 0000000000..ac92623c3a --- /dev/null +++ b/tests/dbal/ext/foo/bar/acp/acp_test_info.php @@ -0,0 +1,37 @@ +<?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 foo\bar\acp; + +class acp_test_info +{ + public function module() + { + return array( + 'filename' => '\foo\bar\acp\acp_test_module', + 'title' => 'ACP_NEW_MODULE', + 'modes' => array( + 'mode_1' => array( + 'title' => 'ACP_NEW_MODULE_MODE_1', + 'auth' => '', + 'cat' => array('ACP_NEW_MODULE'), + ), + 'mode_2' => array( + 'title' => 'ACP_NEW_MODULE_MODE_2', + 'auth' => '', + 'cat' => array('ACP_NEW_MODULE'), + ), + ), + ); + } +} diff --git a/tests/dbal/ext/foo/bar/acp/acp_test_module.php b/tests/dbal/ext/foo/bar/acp/acp_test_module.php new file mode 100644 index 0000000000..01ce5c17dc --- /dev/null +++ b/tests/dbal/ext/foo/bar/acp/acp_test_module.php @@ -0,0 +1,25 @@ +<?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 foo\bar\acp; + +class acp_test_module +{ + var $u_action; + + function main($id, $mode) + { + $this->tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} diff --git a/tests/dbal/ext/foo/bar/composer.json b/tests/dbal/ext/foo/bar/composer.json new file mode 100644 index 0000000000..2edfd43d84 --- /dev/null +++ b/tests/dbal/ext/foo/bar/composer.json @@ -0,0 +1,24 @@ +{ + "name": "foo/bar", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "license": "GNU GPL v2", + "authors": [{ + "name": "John Smith", + "username": "JohnSmith27", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.4.7" + }, + "extra": { + "display-name": "phpBB BarFoo Extension", + "soft-require": { + "phpbb/phpbb": "3.2.*@dev" + } + } +} diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php new file mode 100644 index 0000000000..d3489af832 --- /dev/null +++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_info.php @@ -0,0 +1,37 @@ +<?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 foo\bar\ucp; + +class ucp_test_info +{ + public function module() + { + return array( + 'filename' => '\foo\bar\ucp\ucp_test_module', + 'title' => 'UCP_NEW_MODULE', + 'modes' => array( + 'mode_1' => array( + 'title' => 'UCP_NEW_MODULE_MODE_1', + 'auth' => '', + 'cat' => array('UCP_NEW_MODULE'), + ), + 'mode_2' => array( + 'title' => 'UCP_NEW_MODULE_MODE_2', + 'auth' => '', + 'cat' => array('UCP_NEW_MODULE'), + ), + ), + ); + } +} diff --git a/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php new file mode 100644 index 0000000000..b06b3238b6 --- /dev/null +++ b/tests/dbal/ext/foo/bar/ucp/ucp_test_module.php @@ -0,0 +1,25 @@ +<?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 foo\bar\ucp; + +class ucp_test_module +{ + var $u_action; + + function main($id, $mode) + { + $this->tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 0f3febb24d..e34ee7b59c 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -11,6 +11,9 @@ * */ +require_once dirname(__FILE__) . '/ext/foo/bar/acp/acp_test_info.php'; +require_once dirname(__FILE__) . '/ext/foo/bar/ucp/ucp_test_info.php'; + class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case { public function getDataSet() @@ -39,6 +42,9 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + // Correctly set the root path for this test to this directory, so the classes can be found + $phpbb_root_path = dirname(__FILE__) . '/'; + $phpbb_extension_manager = new phpbb_mock_extension_manager($phpbb_root_path); $module_manager = new \phpbb\module\module_manager($cache, $this->db, $phpbb_extension_manager, MODULES_TABLE, $phpbb_root_path, $phpEx); @@ -403,6 +409,35 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $this->fail($e); } $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_SUBCAT', 'UCP_NEW_MODULE')); + + // Test adding new UCP module the automatic way, single mode + try + { + $this->tool->add('ucp', 'UCP_NEW_CAT', array( + 'module_basename' => '\foo\bar\ucp\ucp_test_module', + 'modes' => array('mode_1'), + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_1')); + $this->assertEquals(false, $this->tool->exists('ucp', 'UCP_NEW_CAT', 'UCP_NEW_MODULE_MODE_2')); + + // Test adding new ACP module the automatic way, all modes + try + { + $this->tool->add('acp', 'ACP_NEW_CAT', array( + 'module_basename' => '\foo\bar\acp\acp_test_module', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_1')); + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE_MODE_2')); } public function test_remove() diff --git a/tests/event/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test index ce8f97ce89..e93a1044ac 100644 --- a/tests/event/fixtures/extra_description.test +++ b/tests/event/fixtures/extra_description.test @@ -3,7 +3,7 @@ /** * Description * -* NOTE: This will not be exported +* NOTE: This will also be exported * * @event extra_description.dispatch * @since 3.1.0-b2 diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 21dbb1e1d4..c6670e1340 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -57,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case 'file' => 'extra_description.test', 'arguments' => array(), 'since' => '3.1.0-b2', - 'description' => 'Description', + 'description' => 'Description<br/><br/>NOTE: This will also be exported', ), ), ), diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php new file mode 100644 index 0000000000..af636f5d21 --- /dev/null +++ b/tests/migrator/get_callable_from_step_test.php @@ -0,0 +1,136 @@ +<?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. + * + */ + +class get_callable_from_step_test extends phpbb_database_test_case +{ + public function setUp() + { + global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log; + + parent::setUp(); + + $phpbb_log = $this->getMockBuilder('\phpbb\log\log')->disableOriginalConstructor()->getMock(); + $db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); + $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock(); + $module_manager = new \phpbb\module\module_manager( + $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(), + $db, + new phpbb_mock_extension_manager($phpbb_root_path), + 'phpbb_modules', + $phpbb_root_path, + $php_ext + ); + $module_tools = new \phpbb\db\migration\tool\module($db, $cache_service, $user, $module_manager, $phpbb_root_path, $php_ext, 'phpbb_modules'); + $this->migrator = new \phpbb\db\migrator( + new phpbb_mock_container_builder(), + new \phpbb\config\config(array()), + $db, + $factory->get($db), + 'phpbb_migrations', + $phpbb_root_path, + $php_ext, + $table_prefix, + array($module_tools), + new \phpbb\db\migration\helper() + ); + + if (!$module_tools->exists('acp', 0, 'new_module_langname')) + { + $module_tools->add('acp', 0, array( + 'module_basename' => 'new_module_basename', + 'module_langname' => 'new_module_langname', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )); + $this->module_added = true; + } + } + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/../dbal/fixtures/migrator.xml'); + } + + public function get_callable_from_step_provider() + { + return array( + array( + array('if', array( + false, + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'mcp', + 'RANDOM_PARENT', + 'RANDOM_MODULE' + )), + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'acp', + 0, + 'new_module_langname' + )), + array('module.add', array( + 'acp', + 0, + 'module_basename' => 'new_module_basename2', + 'module_langname' => 'new_module_langname2', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )), + )), + false, // expects false + ), + ); + } + + /** + * @dataProvider get_callable_from_step_provider + */ + public function test_get_callable_from_step($step, $expects_false) + { + if ($expects_false) + { + $this->assertFalse($this->call_get_callable_from_step($step)); + } + else + { + $this->assertNotFalse($this->call_get_callable_from_step($step)); + } + } + + protected function call_get_callable_from_step($step) + { + $class = new ReflectionClass($this->migrator); + $method = $class->getMethod('get_callable_from_step'); + $method->setAccessible(true); + return $method->invokeArgs($this->migrator, array($step)); + } +} diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php index a9d1ea20de..428db6ac98 100644 --- a/tests/random/gen_rand_string_test.php +++ b/tests/random/gen_rand_string_test.php @@ -40,7 +40,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case $random_string_length = strlen($random_string); $this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH); - $this->assertTrue($random_string_length <= $num_chars); + $this->assertTrue( + $random_string_length == $num_chars, + sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length) + ); $this->assertRegExp('#^[A-Z0-9]+$#', $random_string); } } @@ -56,7 +59,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case $random_string_length = strlen($random_string); $this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH); - $this->assertTrue($random_string_length <= $num_chars); + $this->assertTrue( + $random_string_length == $num_chars, + sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length) + ); $this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string); } } diff --git a/tests/template/context_test.php b/tests/template/context_test.php new file mode 100644 index 0000000000..52ce6c8fde --- /dev/null +++ b/tests/template/context_test.php @@ -0,0 +1,96 @@ +<?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. +* +*/ + +class context_test extends phpbb_test_case +{ + protected $context; + protected function setUp() + { + $this->context = new \phpbb\template\context(); + + for ($i = 0; $i < 10; $i++) + { + $this->context->assign_block_vars('block' . $i, array( + 'FOO' . $i => 'foo' . $i, + 'BAR' . $i => 'bar' . $i, + )); + + for ($j = 0; $j < 10; $j++) + { + $this->context->assign_block_vars('block' . $i . '.subblock', array( + 'SUBFOO' => 'subfoo' . $j, + 'SUBBAR' => 'subbar' . $j, + )); + + for ($k = 0; $k < 10; $k++) + { + $this->context->assign_block_vars('block' . $i . '.subblock.subsubblock', array( + 'SUBSUBFOO' => 'subsubfoo' . $k, + 'SUBSUBBAR' => 'subsubbar' . $k, + )); + } + } + } + } + + public function retrieve_block_vars_data() + { + return array( + array('foo', array(), array()), // non-existent top-level block + array('block1.foo', array(), array()), // non-existent sub-level block + array('block1', array(), array( // top-level block, all vars + 'FOO1' => 'foo1', + 'BAR1' => 'bar1', + )), + array('block1', array('FOO1'), array( // top-level block, one var + 'FOO1' => 'foo1', + )), + array('block2.subblock', array(), array( // sub-level block, all vars + 'SUBFOO' => 'subfoo9', + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock', array('SUBBAR'), array( // sub-level block, one var + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock.subsubblock', array(), array( // sub-sub-level block, all vars + 'SUBSUBFOO' => 'subsubfoo9', + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block2.subblock.subsubblock', array('SUBSUBBAR'), array( // sub-sub-level block, one var + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block3.subblock[2]', array(), array( // sub-level, exact index, all vars + 'SUBFOO' => 'subfoo2', + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[2]', array('SUBBAR'), array( // sub-level, exact index, one var + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[3].subsubblock[5]', array(), array( // sub-sub-level, exact index, all vars + 'SUBSUBFOO' => 'subsubfoo5', + 'SUBSUBBAR' => 'subsubbar5', + )), + array('block3.subblock[4].subsubblock[6]', array('SUBSUBFOO'), array( // sub-sub-level, exact index, one var + 'SUBSUBFOO' => 'subsubfoo6', + )), + ); + } + + /** + * @dataProvider retrieve_block_vars_data + */ + public function test_retrieve_block_vars($blockname, $vararray, $result) + { + $this->assertEquals($result, $this->context->retrieve_block_vars($blockname, $vararray)); + } +} |