diff options
-rw-r--r-- | phpBB/docs/events.md | 7 | ||||
-rw-r--r-- | phpBB/includes/functions_display.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 42 | ||||
-rw-r--r-- | phpBB/language/en/acp/posting.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/plupload/plupload.php | 37 | ||||
-rw-r--r-- | phpBB/phpbb/session.php | 28 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/memberlist_body.html | 9 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/ucp_profile_profile_info.html | 2 | ||||
-rw-r--r-- | phpBB/viewforum.php | 2 | ||||
-rw-r--r-- | tests/plupload/plupload_test.php | 73 | ||||
-rw-r--r-- | tests/test_framework/phpbb_ui_test_case.php | 21 |
11 files changed, 205 insertions, 24 deletions
diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 4be1725090..bfe26b4951 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -2646,6 +2646,13 @@ ucp_profile_profile_info_before * Since: 3.1.4-RC1 * Purpose: Add options in profile page fieldset - before jabber field. +ucp_profile_profile_info_birthday_label_append +=== +* Locations: + + styles/prosilver/template/ucp_profile_profile_info.html +* Since: 3.2.9-RC1 +* Purpose: Add more text to birthday label, such as required asterisk + ucp_profile_register_details_after === * Locations: diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 2d9aaba6e8..1ac18fd3f8 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -70,7 +70,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time(), false) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); @@ -355,7 +355,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time(), false) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index d150845952..45eda4ba17 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -52,9 +52,29 @@ function generate_smilies($mode, $forum_id) page_header($user->lang['SMILIES']); - $sql = 'SELECT COUNT(smiley_id) AS item_count - FROM ' . SMILIES_TABLE . ' - GROUP BY smiley_url'; + $sql_ary = [ + 'SELECT' => 'COUNT(s.smiley_id) AS item_count', + 'FROM' => [ + SMILIES_TABLE => 's', + ], + 'GROUP_BY' => 's.smiley_url', + ]; + + /** + * Modify SQL query that fetches the total number of smilies in window mode + * + * @event core.generate_smilies_count_sql_before + * @var int forum_id Forum where smilies are generated + * @var array sql_ary Array with the SQL query + * @since 3.2.9-RC1 + */ + $vars = [ + 'forum_id', + 'sql_ary', + ]; + extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars))); + + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query($sql, 3600); $smiley_count = 0; @@ -114,6 +134,22 @@ function generate_smilies($mode, $forum_id) } $db->sql_freeresult($result); + /** + * Modify smilies before they are assigned to the template + * + * @event core.generate_smilies_modify_rowset + * @var string mode Smiley mode, either window or inline + * @var int forum_id Forum where smilies are generated + * @var array smilies Smiley rows fetched from the database + * @since 3.2.9-RC1 + */ + $vars = [ + 'mode', + 'forum_id', + 'smilies', + ]; + extract($phpbb_dispatcher->trigger_event('core.generate_smilies_modify_rowset', compact($vars))); + if (count($smilies)) { $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 119ad2d7e9..1e1c5554e1 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -78,13 +78,13 @@ $lang = array_merge($lang, array( 'TOO_MANY_BBCODES' => 'You cannot create any more BBCodes. Please remove one or more BBCodes then try again.', 'tokens' => array( - 'TEXT' => 'Any text, including foreign characters, numbers, etc… You should not use this token in HTML tags. Instead try to use IDENTIFIER, INTTEXT or SIMPLETEXT.', + 'TEXT' => 'Any text, including foreign characters, numbers, etc…', 'SIMPLETEXT' => 'Characters from the latin alphabet (A-Z), numbers, spaces, commas, dots, minus, plus, hyphen and underscore', 'INTTEXT' => 'Unicode letter characters, numbers, spaces, commas, dots, minus, plus, hyphen, underscore and whitespaces.', 'IDENTIFIER' => 'Characters from the latin alphabet (A-Z), numbers, hyphen and underscore', 'NUMBER' => 'Any series of digits', 'EMAIL' => 'A valid email address', - 'URL' => 'A valid URL using any protocol (http, ftp, etc… cannot be used for javascript exploits). If none is given, “http://” is prefixed to the string.', + 'URL' => 'A valid URL using any allowed protocol (http, ftp, etc… cannot be used for javascript exploits). If none is given, “http://” is prefixed to the string.', 'LOCAL_URL' => 'A local URL. The URL must be relative to the topic page and cannot contain a server name or protocol, as links are prefixed with “%s”', 'RELATIVE_URL' => 'A relative URL. You can use this to match parts of a URL, but be careful: a full URL is a valid relative URL. When you want to use relative URLs of your board, use the LOCAL_URL token.', 'COLOR' => 'A HTML colour, can be either in the numeric form <samp>#FF1234</samp> or a <a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-color">CSS colour keyword</a> such as <samp>fuchsia</samp> or <samp>InactiveBorder</samp>', diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 9ad12b1082..5a5b8a1874 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -274,22 +274,37 @@ class plupload } /** - * Checks various php.ini values and the maximum file size to determine - * the maximum size chunks a file can be split up into for upload - * - * @return int - */ + * Checks various php.ini values to determine the maximum chunk + * size a file should be split into for upload. + * + * The intention is to calculate a value which reflects whatever + * the most restrictive limit is set to. And to then set the chunk + * size to half that value, to ensure any required transfer overhead + * and POST data remains well within the limit. Or, if all of the + * limits are set to unlimited, the chunk size will also be unlimited. + * + * @return int + * + * @access public + */ public function get_chunk_size() { - $max = min( + $max = 0; + + $limits = [ + $this->php_ini->getBytes('memory_limit'), $this->php_ini->getBytes('upload_max_filesize'), $this->php_ini->getBytes('post_max_size'), - max(1, $this->php_ini->getBytes('memory_limit')), - $this->config['max_filesize'] - ); + ]; + + foreach ($limits as $limit_type) + { + if ($limit_type > 0) + { + $max = ($max !== 0) ? min($limit_type, $max) : $limit_type; + } + } - // Use half of the maximum possible to leave plenty of room for other - // POST data. return floor($max / 2); } diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 38e40ba29e..7624a67b05 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1077,7 +1077,7 @@ class session */ function set_cookie($name, $cookiedata, $cookietime, $httponly = true) { - global $config; + global $config, $phpbb_dispatcher; // If headers are already set, we just return if (headers_sent()) @@ -1085,6 +1085,32 @@ class session return; } + $disable_cookie = false; + /** + * Event to modify or disable setting cookies + * + * @event core.set_cookie + * @var bool disable_cookie Set to true to disable setting this cookie + * @var string name Name of the cookie + * @var string cookiedata The data to hold within the cookie + * @var int cookietime The expiration time as UNIX timestamp + * @var bool httponly Use HttpOnly? + * @since 3.2.9-RC1 + */ + $vars = array( + 'disable_cookie', + 'name', + 'cookiedata', + 'cookietime', + 'httponly', + ); + extract($phpbb_dispatcher->trigger_event('core.set_cookie', compact($vars))); + + if ($disable_cookie) + { + return; + } + $name_data = rawurlencode($config['cookie_name'] . '_' . $name) . '=' . rawurlencode($cookiedata); $expire = gmdate('D, d-M-Y H:i:s \\G\\M\\T', $cookietime); $domain = (!$config['cookie_domain'] || $config['cookie_domain'] == '127.0.0.1' || strpos($config['cookie_domain'], '.') === false) ? '' : '; domain=' . $config['cookie_domain']; diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 745f9a58a8..b8ff092372 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -28,8 +28,13 @@ <p> <!-- IF AVATAR_IMG -->{AVATAR_IMG}<!-- ENDIF --> {% EVENT memberlist_body_group_rank_before %} - <!-- IF RANK_IMG -->{RANK_IMG}<!-- ENDIF --> - <!-- IF GROUP_RANK -->{GROUP_RANK}<!-- ENDIF --> + {% if RANK_IMG %}{{ RANK_IMG }}{% endif %} + {% if GROUP_RANK %} + {% if not RANK_IMG %} + {{ lang('GROUP_RANK') ~ lang('COLON') }} + {% endif %} + {{ GROUP_RANK }} + {% endif %} {% EVENT memberlist_body_group_rank_after %} </p> <!-- ELSE --> diff --git a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html index 69eda8c42c..ac0cd153c2 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_profile_info.html +++ b/phpBB/styles/prosilver/template/ucp_profile_profile_info.html @@ -13,7 +13,7 @@ <!-- EVENT ucp_profile_profile_info_before --> <!-- IF S_BIRTHDAYS_ENABLED --> <dl> - <dt><label for="bday_day">{L_BIRTHDAY}{L_COLON}</label><br /><span>{L_BIRTHDAY_EXPLAIN}</span></dt> + <dt><label for="bday_day">{L_BIRTHDAY}{L_COLON}{% EVENT ucp_profile_profile_info_birthday_label_append %}</label><br /><span>{L_BIRTHDAY_EXPLAIN}</span></dt> <dd> <label for="bday_day">{L_DAY}{L_COLON} <select name="bday_day" id="bday_day">{S_BIRTHDAY_DAY_OPTIONS}</select></label> <label for="bday_month">{L_MONTH}{L_COLON} <select name="bday_month" id="bday_month">{S_BIRTHDAY_MONTH_OPTIONS}</select></label> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 0a5484cdf2..4691512cbd 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -222,7 +222,7 @@ if ($mark_read == 'topics') $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], - 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time()) : '', + 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics&mark_time=" . time(), false) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['TOPICS_MARKED'] ); diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index 46bebb8d35..eb4657afbc 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -54,4 +54,77 @@ class phpbb_plupload_test extends phpbb_test_case $this->assertEquals($expected, $plupload->generate_resize_string()); } + + public function data_get_chunk_size() + { + return [ + [[ + 'memory_limit' => -1, + 'upload_max_filesize' => 0, + 'post_max_size' => 0, + ], 0], + [[ + 'memory_limit' => -1, + 'upload_max_filesize' => 500, + 'post_max_size' => 400, + ], 200], + [[ + 'memory_limit' => 100, + 'upload_max_filesize' => 0, + 'post_max_size' => 300, + ], 50], + [[ + 'memory_limit' => 300, + 'upload_max_filesize' => 200, + 'post_max_size' => 0, + ], 100], + [[ + 'memory_limit' => 3000, + 'upload_max_filesize' => 800, + 'post_max_size' => 900, + ], 400], + [[ + 'memory_limit' => 2000, + 'upload_max_filesize' => 1000, + 'post_max_size' => 600, + ], 300], + [[ + 'memory_limit' => 1000, + 'upload_max_filesize' => 2000, + 'post_max_size' => 3000, + ], 500], + ]; + } + + /** + * @dataProvider data_get_chunk_size + */ + public function test_get_chunk_size($limits_ary, $expected) + { + global $phpbb_root_path, $phpEx; + + $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + $config = new \phpbb\config\config([]); + + $ini_wrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') + ->setMethods(['getBytes']) + ->getMock(); + $ini_wrapper->method('getBytes') + ->will($this->returnValueMap([ + ['memory_limit', $limits_ary['memory_limit']], + ['upload_max_filesize', $limits_ary['upload_max_filesize']], + ['post_max_size', $limits_ary['post_max_size']] + ])); + + $plupload = new \phpbb\plupload\plupload( + '', + $config, + new phpbb_mock_request, + new \phpbb\user($lang, '\phpbb\datetime'), + $ini_wrapper, + new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)) + ); + + $this->assertEquals($expected, $plupload->get_chunk_size()); + } } diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 6d6d29d001..fcac3594d0 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -153,7 +153,26 @@ class phpbb_ui_test_case extends phpbb_test_case public function visit($path) { - $this->getDriver()->get(self::$root_url . $path); + // Retry three times on curl issues, e.g. timeout + $attempts = 0; + $retries = 3; + + while (true) + { + $attempts++; + try + { + $this->getDriver()->get(self::$root_url . $path); + break; + } + catch (Facebook\WebDriver\Exception\WebDriverCurlException $exception) + { + if ($attempts >= $retries) + { + throw $exception; + } + } + } } static protected function recreate_database($config) |