diff options
49 files changed, 601 insertions, 355 deletions
diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php deleted file mode 100755 index 100ac53b33..0000000000 --- a/git-tools/setup_github_network.php +++ /dev/null @@ -1,292 +0,0 @@ -#!/usr/bin/env php -<?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. -* -*/ - -function show_usage() -{ - $filename = basename(__FILE__); - - echo "$filename adds repositories of a github network as remotes to a local git repository.\n"; - echo "\n"; - - echo "Usage: [php] $filename -s collaborators|organisation|contributors|forks [OPTIONS]\n"; - echo "\n"; - - echo "Scopes:\n"; - echo " collaborators Repositories of people who have push access to the specified repository\n"; - echo " contributors Repositories of people who have contributed to the specified repository\n"; - echo " organisation Repositories of members of the organisation at github\n"; - echo " forks All repositories of the whole github network\n"; - echo "\n"; - - echo "Options:\n"; - echo " -s scope See description above (mandatory)\n"; - echo " -u github_username Overwrites the github username (optional)\n"; - echo " -r repository_name Overwrites the repository name (optional)\n"; - echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n"; - echo " -d Outputs the commands instead of running them (optional)\n"; - echo " -h This help text\n"; - - exit(1); -} - -// Handle arguments -$opts = getopt('s:u:r:m:dh'); - -if (empty($opts) || isset($opts['h'])) -{ - show_usage(); -} - -$scope = get_arg($opts, 's', ''); -$username = get_arg($opts, 'u', 'phpbb'); -$repository = get_arg($opts, 'r', 'phpbb3'); -$developer = get_arg($opts, 'm', ''); -$dry_run = !get_arg($opts, 'd', true); -run(null, $dry_run); -exit(work($scope, $username, $repository, $developer)); - -function work($scope, $username, $repository, $developer) -{ - // Get some basic data - $forks = get_forks($username, $repository); - $collaborators = get_collaborators($username, $repository); - - if ($forks === false || $collaborators === false) - { - echo "Error: failed to retrieve forks or collaborators\n"; - return 1; - } - - switch ($scope) - { - case 'collaborators': - $remotes = array_intersect_key($forks, $collaborators); - break; - - case 'organisation': - $remotes = array_intersect_key($forks, get_organisation_members($username)); - break; - - case 'contributors': - $remotes = array_intersect_key($forks, get_contributors($username, $repository)); - break; - - case 'forks': - $remotes = $forks; - break; - - default: - show_usage(); - } - - if (file_exists('.git')) - { - add_remote($username, $repository, isset($collaborators[$developer])); - } - else - { - clone_repository($username, $repository, isset($collaborators[$developer])); - } - - // Add private security repository for developers - if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer])) - { - run("git remote add $username-security " . get_repository_url($username, "$repository-security", true)); - } - - // Skip blessed repository. - unset($remotes[$username]); - - foreach ($remotes as $remote) - { - add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer); - } - - run('git remote update'); -} - -function clone_repository($username, $repository, $pushable = false) -{ - $url = get_repository_url($username, $repository, false); - run("git clone $url ./ --origin $username"); - - if ($pushable) - { - $ssh_url = get_repository_url($username, $repository, true); - run("git remote set-url --push $username $ssh_url"); - } -} - -function add_remote($username, $repository, $pushable = false) -{ - $url = get_repository_url($username, $repository, false); - run("git remote add $username $url"); - - if ($pushable) - { - $ssh_url = get_repository_url($username, $repository, true); - run("git remote set-url --push $username $ssh_url"); - } -} - -function get_repository_url($username, $repository, $ssh = false) -{ - $url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/'; - - return $url_base . $username . '/' . $repository . '.git'; -} - -function api_request($query) -{ - return api_url_request("https://api.github.com/$query?per_page=100"); -} - -function api_url_request($url) -{ - $contents = file_get_contents($url, false, stream_context_create(array( - 'http' => array( - 'header' => "User-Agent: phpBB/1.0\r\n", - ), - ))); - - $sub_request_result = array(); - // Check headers for pagination links - if (!empty($http_response_header)) - { - foreach ($http_response_header as $header_element) - { - // Find Link Header which gives us a link to the next page - if (strpos($header_element, 'Link: ') === 0) - { - list($head, $header_content) = explode(': ', $header_element); - foreach (explode(', ', $header_content) as $links) - { - list($url, $rel) = explode('; ', $links); - if ($rel == 'rel="next"') - { - // Found a next link, follow it and merge the results - $sub_request_result = api_url_request(substr($url, 1, -1)); - } - } - } - } - } - - if ($contents === false) - { - return false; - } - $contents = json_decode($contents); - - if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0) - { - throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4); - } - - return ($sub_request_result) ? array_merge($sub_request_result, $contents) : $contents; -} - -function get_contributors($username, $repository) -{ - $request = api_request("repos/$username/$repository/stats/contributors"); - if ($request === false) - { - return false; - } - - $usernames = array(); - foreach ($request as $contribution) - { - $usernames[$contribution->author->login] = $contribution->author->login; - } - - return $usernames; -} - -function get_organisation_members($username) -{ - $request = api_request("orgs/$username/public_members"); - if ($request === false) - { - return false; - } - - $usernames = array(); - foreach ($request as $member) - { - $usernames[$member->login] = $member->login; - } - - return $usernames; -} - -function get_collaborators($username, $repository) -{ - $request = api_request("repos/$username/$repository/collaborators"); - if ($request === false) - { - return false; - } - - $usernames = array(); - foreach ($request as $collaborator) - { - $usernames[$collaborator->login] = $collaborator->login; - } - - return $usernames; -} - -function get_forks($username, $repository) -{ - $request = api_request("repos/$username/$repository/forks"); - if ($request === false) - { - return false; - } - - $usernames = array(); - foreach ($request as $fork) - { - $usernames[$fork->owner->login] = array( - 'username' => $fork->owner->login, - 'repository' => $fork->name, - ); - } - - return $usernames; -} - -function get_arg($array, $index, $default) -{ - return isset($array[$index]) ? $array[$index] : $default; -} - -function run($cmd, $dry = false) -{ - static $dry_run; - - if (is_null($cmd)) - { - $dry_run = $dry; - } - else if (!empty($dry_run)) - { - echo "$cmd\n"; - } - else - { - passthru(escapeshellcmd($cmd)); - } -} diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html index 830c2e3cb4..465a89e17a 100644 --- a/phpBB/adm/style/acp_ext_details.html +++ b/phpBB/adm/style/acp_ext_details.html @@ -136,4 +136,5 @@ <!-- END meta_authors --> </fieldset> + <!-- EVENT acp_ext_details_end --> <!-- INCLUDE overall_footer.html --> diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index efcb25cb68..1bdb7b8d2a 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -30,6 +30,11 @@ <p><a href="{U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE}</a> · <a href="{U_VERSIONCHECK}">{L_MORE_INFORMATION}</a></p> </div> <!-- ENDIF --> + <!-- IF S_VERSION_UPGRADEABLE --> + <div class="errorbox notice"> + <p>{UPGRADE_INSTRUCTIONS}</p> + </div> + <!-- ENDIF --> <!-- IF S_SEARCH_INDEX_MISSING --> <div class="errorbox"> diff --git a/phpBB/adm/style/acp_update.html b/phpBB/adm/style/acp_update.html index 351a3ba26c..5288833d05 100644 --- a/phpBB/adm/style/acp_update.html +++ b/phpBB/adm/style/acp_update.html @@ -20,6 +20,11 @@ <p>{L_VERSION_NOT_UP_TO_DATE_ACP} - <a href="{U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE}</a></p> </div> <!-- ENDIF --> +<!-- IF S_VERSION_UPGRADEABLE --> + <div class="errorbox notice"> + <p>{UPGRADE_INSTRUCTIONS}</p> + </div> +<!-- ENDIF --> <fieldset> <legend></legend> diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index a7ecf8ff7b..77fd28fbe6 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -173,10 +173,11 @@ function submitPermissions() { $.ajax({ url: $form.action, type: 'POST', - data: formData + '&' + $submitAllButton.name + '=' + encodeURIComponent($submitAllButton.value) + + data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value) + '&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value + '&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value + - '&' + $form.children('input[type=hidden]').serialize(), + '&' + $form.children('input[type=hidden]').serialize() + + '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(), success: handlePermissionReturn, error: handlePermissionReturn }); diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index d399c680ee..bd8caf1443 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -53,7 +53,7 @@ function marklist(id, name, state) for (var r = 0; r < rb.length; r++) { - if (rb[r].name.substr(0, name.length) == name) + if (rb[r].name.substr(0, name.length) == name && rb[r].disabled !== true) { rb[r].checked = state; } diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 9f47b2052b..439645a211 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -66,7 +66,7 @@ function marklist(id, name, state) for (var r = 0; r < rb.length; r++) { - if (rb[r].name.substr(0, name.length) == name) + if (rb[r].name.substr(0, name.length) == name && rb[r].disabled !== true) { rb[r].checked = state; } diff --git a/phpBB/config/db.yml b/phpBB/config/db.yml index d11669d8a3..4ab4401bbd 100644 --- a/phpBB/config/db.yml +++ b/phpBB/config/db.yml @@ -5,9 +5,7 @@ services: - @service_container dbal.conn.driver: - class: %dbal.driver.class% - calls: - - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] + synthetic: true dbal.tools: class: phpbb\db\tools diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 12a8a3dfeb..b1a962cfb0 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -58,6 +58,12 @@ acp_email_options_after * Since: 3.1.2-RC1 * Purpose: Add settings to mass email form +acp_ext_details_end +=== +* Location: adm/style/acp_ext_details.html +* Since: 3.1.11-RC1 +* Purpose: Add more detailed information on extension after the available information. + acp_ext_list_disabled_title_after === * Location: adm/style/acp_ext_list.html @@ -1057,6 +1063,22 @@ memberlist_search_sorting_options_before * Since: 3.1.2-RC1 * Purpose: Add information before the search sorting options field. +memberlist_team_username_append +=== +* Locations: + + styles/prosilver/template/memberlist_team.html + + styles/subsilver2/template/memberlist_team.html +* Since: 3.1.11-RC1 +* Purpose: Append information to username of team member + +memberlist_team_username_prepend +=== +* Locations: + + styles/prosilver/template/memberlist_team.html + + styles/subsilver2/template/memberlist_team.html +* Since: 3.1.11-RC1 +* Purpose: Add information before team user username + memberlist_view_contact_after === * Locations: diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 848cafeb67..6e7bd91a86 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -421,23 +421,33 @@ class acp_main // Version check $user->add_lang('install'); - if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.3.3', '<')) + if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.4.0', '<')) { $template->assign_vars(array( 'S_PHP_VERSION_OLD' => true, - 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '<a href="https://www.phpbb.com/community/viewtopic.php?f=14&t=2152375">', '</a>'), + 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], PHP_VERSION, '5.4.0', '<a href="https://www.phpbb.com/support/docs/en/3.2/ug/quickstart/requirements">', '</a>'), )); } if ($auth->acl_get('a_board')) { + /** @var \phpbb\version_helper $version_helper */ $version_helper = $phpbb_container->get('version_helper'); try { $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_suggested_updates($recheck); + $updates_available = $version_helper->get_update_on_branch($recheck); + $upgrades_available = $version_helper->get_suggested_updates(); + if (!empty($upgrades_available)) + { + $upgrades_available = array_pop($upgrades_available); + } - $template->assign_var('S_VERSION_UP_TO_DATE', empty($updates_available)); + $template->assign_vars(array( + 'S_VERSION_UP_TO_DATE' => empty($updates_available), + 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), + 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, + )); } catch (\RuntimeException $e) { diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index 529f0f2185..51ff4870f2 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -37,7 +37,12 @@ class acp_update try { $recheck = $request->variable('versioncheck_force', false); - $updates_available = $version_helper->get_suggested_updates($recheck); + $updates_available = $version_helper->get_update_on_branch($recheck); + $upgrades_available = $version_helper->get_suggested_updates(); + if (!empty($upgrades_available)) + { + $upgrades_available = array_pop($upgrades_available); + } } catch (\RuntimeException $e) { @@ -51,7 +56,7 @@ class acp_update $template->assign_block_vars('updates_available', $version_data); } - $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update'); + $update_link = append_sid($phpbb_root_path . 'install/'); $template->assign_vars(array( 'S_UP_TO_DATE' => empty($updates_available), @@ -61,6 +66,8 @@ class acp_update 'CURRENT_VERSION' => $config['version'], 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $update_link), + 'S_VERSION_UPGRADEABLE' => !empty($upgrades_available), + 'UPGRADE_INSTRUCTIONS' => !empty($upgrades_available) ? $user->lang('UPGRADE_INSTRUCTIONS', $upgrades_available['current'], $upgrades_available['announcement']) : false, )); // Incomplete update? diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 1dc246ec33..4bac718999 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -641,8 +641,8 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) * * @event core.move_posts_before * @var array post_ids Array of post ids to move - * @var string topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync + * @var int topic_id The topic id the posts are moved to + * @var bool auto_sync Whether or not to perform auto sync * @var array forum_ids Array of the forum ids the posts are moved from * @var array topic_ids Array of the topic ids the posts are moved from * @var array forum_row Array with the forum id of the topic the posts are moved to @@ -673,8 +673,8 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) * * @event core.move_posts_after * @var array post_ids Array of the moved post ids - * @var string topic_id The topic id the posts are moved to - * @var bool auto_sync Whether or not to perform auto sync + * @var int topic_id The topic id the posts are moved to + * @var bool auto_sync Whether or not to perform auto sync * @var array forum_ids Array of the forum ids the posts are moved from * @var array topic_ids Array of the topic ids the posts are moved from * @var array forum_row Array with the forum id of the topic the posts are moved to @@ -698,6 +698,28 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) sync('topic_attachment', 'topic_id', $topic_ids); sync('topic', 'topic_id', $topic_ids, true); sync('forum', 'forum_id', $forum_ids, true, true); + + /** + * Perform additional actions after move post sync + * + * @event core.move_posts_sync_after + * @var array post_ids Array of the moved post ids + * @var int topic_id The topic id the posts are moved to + * @var bool auto_sync Whether or not to perform auto sync + * @var array forum_ids Array of the forum ids the posts are moved from + * @var array topic_ids Array of the topic ids the posts are moved from + * @var array forum_row Array with the forum id of the topic the posts are moved to + * @since 3.1.11-RC1 + */ + $vars = array( + 'post_ids', + 'topic_id', + 'auto_sync', + 'forum_ids', + 'topic_ids', + 'forum_row', + ); + extract($phpbb_dispatcher->trigger_event('core.move_posts_sync_after', compact($vars))); } // Update posted information diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php index 86c60c31ff..053e362682 100644 --- a/phpBB/includes/functions_download.php +++ b/phpBB/includes/functions_download.php @@ -124,7 +124,7 @@ function wrap_img_in_html($src, $title) */ function send_file_to_browser($attachment, $upload_dir, $category) { - global $user, $db, $config, $phpbb_root_path; + global $user, $db, $config, $phpbb_dispatcher, $phpbb_root_path; $filename = $phpbb_root_path . $upload_dir . '/' . $attachment['physical_filename']; @@ -149,6 +149,26 @@ function send_file_to_browser($attachment, $upload_dir, $category) // Now send the File Contents to the Browser $size = @filesize($filename); + /** + * Event to alter attachment before it is sent to browser. + * + * @event core.send_file_to_browser_before + * @var array attachment Attachment data + * @var string upload_dir Relative path of upload directory + * @var int category Attachment category + * @var string filename Path to file, including filename + * @var int size File size + * @since 3.1.11-RC1 + */ + $vars = array( + 'attachment', + 'upload_dir', + 'category', + 'filename', + 'size', + ); + extract($phpbb_dispatcher->trigger_event('core.send_file_to_browser_before', compact($vars))); + // To correctly display further errors we need to make sure we are using the correct headers for both (unsetting content-length may not work) // Check if headers already sent or not able to get the file contents. diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0b39339c7f..c78beaa6a5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1291,7 +1291,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas */ function user_unban($mode, $ban) { - global $db, $user, $auth, $cache; + global $db, $user, $auth, $cache, $phpbb_dispatcher; // Delete stale bans $sql = 'DELETE FROM ' . BANLIST_TABLE . ' @@ -1358,6 +1358,20 @@ function user_unban($mode, $ban) add_log('user', $user_id, 'LOG_UNBAN_' . strtoupper($mode), $l_unban_list); } } + + /** + * Use this event to perform actions after the unban has been performed + * + * @event core.user_unban + * @var string mode One of the following: user, ip, email + * @var array user_ids_ary Array with user_ids + * @since 3.1.11-RC1 + */ + $vars = array( + 'mode', + 'user_ids_ary', + ); + extract($phpbb_dispatcher->trigger_event('core.user_unban', compact($vars))); } $cache->destroy('sql', BANLIST_TABLE); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index e4c0640ec7..3deb58b96a 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -458,7 +458,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) return; } - $redirect = request_var('redirect', build_url(array('quickmod'))); + $redirect = request_var('redirect', "{$phpbb_root_path}mcp.$phpEx?f=$forum_id&i=main&mode=forum_view"); $s_hidden_fields = build_hidden_fields(array( 'i' => 'main', diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 3ae7876a72..3364206680 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -547,7 +547,7 @@ function get_pm_from($folder_id, $folder, $user_id) AND $folder_sql AND t.msg_id = p.msg_id $sql_limit_time", - 'ORDER' => $sql_sort_order, + 'ORDER_BY' => $sql_sort_order, ); /** diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 88e60d00a3..562b446f8a 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -373,7 +373,7 @@ $lang = array_merge($lang, array( 'NUMBER_USERS' => 'Number of users', 'NUMBER_ORPHAN' => 'Orphan attachments', - 'PHP_VERSION_OLD' => 'The version of PHP on this server will no longer be supported by future versions of phpBB. %sDetails%s', + 'PHP_VERSION_OLD' => 'The version of PHP on this server (%1$s) will no longer be supported by future versions of phpBB. The minimum required version will be PHP %2$s. %3$sDetails%4$s', 'POSTS_PER_DAY' => 'Posts per day', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index a2cfd958aa..b4b328e90d 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -336,6 +336,7 @@ $lang = array_merge($lang, array( 'INTERESTS' => 'Interests', 'INVALID_DIGEST_CHALLENGE' => 'Invalid digest challenge.', 'INVALID_EMAIL_LOG' => '<strong>%s</strong> possibly an invalid email address?', + 'INVALID_FEED_ATTACHMENTS' => 'The selected feed tried fetching attachments with invalid constraints.', 'INVALID_PLURAL_RULE' => 'The chosen plural rule is invalid. Valid values are integers between 0 and 15.', 'IP' => 'IP', 'IP_BLACKLISTED' => 'Your IP %1$s has been blocked because it is blacklisted. For details please see <a href="%2$s">%2$s</a>.', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 6477a929e9..0460c0613e 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -574,6 +574,7 @@ $lang = array_merge($lang, array( 'UPDATING_DATA' => 'Updating data', 'UPDATING_TO_LATEST_STABLE' => 'Updating database to latest stable release', 'UPDATED_VERSION' => 'Updated version', + 'UPGRADE_INSTRUCTIONS' => 'A new feature release <strong>%1$s</strong> is available. Please read <a href="%2$s" title="%2$s"><strong>the release announcement</strong></a> to learn about what it has to offer, and how to upgrade.', 'UPLOAD_METHOD' => 'Upload method', 'UPDATE_DB_SUCCESS' => 'Database update was successful.', diff --git a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php index 2d4d26ae61..d43d432dd9 100644 --- a/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php +++ b/phpBB/phpbb/db/migration/data/v310/notification_options_reconvert.php @@ -52,6 +52,7 @@ class notification_options_reconvert extends \phpbb\db\migration\migration { $limit = 250; $converted_users = 0; + $start = $start ?: 0; $sql = 'SELECT user_id, user_notify_type, user_notify_pm FROM ' . $this->table_prefix . 'users diff --git a/phpBB/phpbb/db/migration/profilefield_base_migration.php b/phpBB/phpbb/db/migration/profilefield_base_migration.php index da1a38e2fa..b20ca874be 100644 --- a/phpBB/phpbb/db/migration/profilefield_base_migration.php +++ b/phpBB/phpbb/db/migration/profilefield_base_migration.php @@ -191,6 +191,7 @@ abstract class profilefield_base_migration extends container_aware_migration $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'profile_fields_data'); $limit = 250; $converted_users = 0; + $start = $start ?: 0; $sql = 'SELECT user_id, ' . $this->user_column_name . ' FROM ' . $this->table_prefix . 'users diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index a214356ac3..5f3aa685bf 100644 --- a/phpBB/phpbb/di/container_builder.php +++ b/phpBB/phpbb/di/container_builder.php @@ -185,6 +185,7 @@ class container_builder } $this->container->set('config.php', $this->config_php_file); + $this->inject_dbal_driver(); if ($this->compile_container) { @@ -304,6 +305,18 @@ class container_builder } /** + * Inject the dbal connection driver into container + */ + protected function inject_dbal_driver() + { + $config_data = $this->config_php_file->get_all(); + if (!empty($config_data)) + { + $this->container->set('dbal.conn.driver', $this->get_dbal_connection()); + } + } + + /** * Get DB connection. * * @return \phpbb\db\driver\driver_interface @@ -320,6 +333,7 @@ class container_builder $this->config_php_file->get('dbpasswd'), $this->config_php_file->get('dbname'), $this->config_php_file->get('dbport'), + false, defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK ); } diff --git a/phpBB/phpbb/di/extension/config.php b/phpBB/phpbb/di/extension/config.php index 7984a783df..8c9de48823 100644 --- a/phpBB/phpbb/di/extension/config.php +++ b/phpBB/phpbb/di/extension/config.php @@ -43,12 +43,6 @@ class config extends Extension 'core.adm_relative_path' => $this->config_php->get('phpbb_adm_relative_path') ? $this->config_php->get('phpbb_adm_relative_path') : 'adm/', 'core.table_prefix' => $this->config_php->get('table_prefix'), 'cache.driver.class' => $this->convert_30_acm_type($this->config_php->get('acm_type')), - 'dbal.driver.class' => $this->config_php->convert_30_dbms_to_31($this->config_php->get('dbms')), - 'dbal.dbhost' => $this->config_php->get('dbhost'), - 'dbal.dbuser' => $this->config_php->get('dbuser'), - 'dbal.dbpasswd' => $this->config_php->get('dbpasswd'), - 'dbal.dbname' => $this->config_php->get('dbname'), - 'dbal.dbport' => $this->config_php->get('dbport'), 'dbal.new_link' => defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK, ); $parameter_bag = $container->getParameterBag(); diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index 34e2910a33..107907609b 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -230,7 +230,20 @@ class metadata_manager case 'all': $this->validate('display'); - $this->validate_enable(); + if (!$this->validate_dir()) + { + throw new \phpbb\extension\exception($this->user->lang('EXTENSION_DIR_INVALID')); + } + + if (!$this->validate_require_phpbb()) + { + throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'soft-require')); + } + + if (!$this->validate_require_php()) + { + throw new \phpbb\extension\exception($this->user->lang('META_FIELD_NOT_SET', 'require php')); + } break; case 'display': diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php index 04812f1570..df8f29a626 100644 --- a/phpBB/phpbb/feed/attachments_base.php +++ b/phpBB/phpbb/feed/attachments_base.php @@ -25,8 +25,11 @@ abstract class attachments_base extends \phpbb\feed\base /** * Retrieve the list of attachments that may be displayed + * + * @param array $post_ids Specify for which post IDs to fetch the attachments (optional) + * @param array $topic_ids Specify for which topic IDs to fetch the attachments (optional) */ - protected function fetch_attachments() + protected function fetch_attachments($post_ids = array(), $topic_ids = array()) { $sql_array = array( 'SELECT' => 'a.*', @@ -37,7 +40,20 @@ abstract class attachments_base extends \phpbb\feed\base 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC', ); - if (isset($this->topic_id)) + if (!empty($post_ids)) + { + $sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.post_msg_id', $post_ids); + } + else if (!empty($topic_ids)) + { + if (isset($this->topic_id)) + { + $topic_ids[] = $this->topic_id; + } + + $sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.topic_id', $topic_ids); + } + else if (isset($this->topic_id)) { $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; } @@ -51,6 +67,11 @@ abstract class attachments_base extends \phpbb\feed\base ); $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; } + else + { + // Do not allow querying the full attachments table + throw new \RuntimeException($this->user->lang('INVALID_FEED_ATTACHMENTS')); + } $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query($sql); @@ -64,15 +85,6 @@ abstract class attachments_base extends \phpbb\feed\base } /** - * {@inheritDoc} - */ - public function open() - { - parent::open(); - $this->fetch_attachments(); - } - - /** * Get attachments related to a given post * * @param $post_id int Post id diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 7a2087c1cd..6aba12a147 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -112,6 +112,8 @@ class forum extends \phpbb\feed\post_base return false; } + parent::fetch_attachments(array(), $topic_ids); + $this->sql = array( 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 'u.username, u.user_id', diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index a02c199d85..5d4786518b 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -83,6 +83,8 @@ class news extends \phpbb\feed\topic_base return false; } + parent::fetch_attachments($post_ids); + $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, diff --git a/phpBB/phpbb/feed/overall.php b/phpBB/phpbb/feed/overall.php index ab452f5386..1176a9c182 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -52,6 +52,8 @@ class overall extends \phpbb\feed\post_base return false; } + parent::fetch_attachments(array(), $topic_ids); + // Get the actual data $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, ' . diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 66c49e55cf..295bf3f795 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -91,6 +91,8 @@ class topic extends \phpbb\feed\post_base function get_sql() { + parent::fetch_attachments(); + $this->sql = array( 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 'u.username, u.user_id', diff --git a/phpBB/phpbb/feed/topics.php b/phpBB/phpbb/feed/topics.php index 2b9cb3501a..e6416bc064 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -55,6 +55,8 @@ class topics extends \phpbb\feed\topic_base return false; } + parent::fetch_attachments($post_ids); + $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, diff --git a/phpBB/phpbb/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php index 6d5eddfc16..3b751f3233 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -71,6 +71,8 @@ class topics_active extends \phpbb\feed\topic_base return false; } + parent::fetch_attachments($post_ids); + $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 9faf5ca08b..f8bda9ae81 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -942,38 +942,45 @@ class fulltext_mysql extends \phpbb\search\base $this->get_stats(); } - $alter = array(); + $alter_list = array(); if (!isset($this->stats['post_subject'])) { + $alter_entry = array(); if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) { - $alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL'; + $alter_entry[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL'; } else { - $alter[] = 'MODIFY post_subject text NOT NULL'; + $alter_entry[] = 'MODIFY post_subject text NOT NULL'; } - $alter[] = 'ADD FULLTEXT (post_subject)'; + $alter_entry[] = 'ADD FULLTEXT (post_subject)'; + $alter_list[] = $alter_entry; } if (!isset($this->stats['post_content'])) { + $alter_entry = array(); if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) { - $alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL'; + $alter_entry[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL'; } else { - $alter[] = 'MODIFY post_text mediumtext NOT NULL'; + $alter_entry[] = 'MODIFY post_text mediumtext NOT NULL'; } - $alter[] = 'ADD FULLTEXT post_content (post_text, post_subject)'; + $alter_entry[] = 'ADD FULLTEXT post_content (post_text, post_subject)'; + $alter_list[] = $alter_entry; } - if (sizeof($alter)) + if (sizeof($alter_list)) { - $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); + foreach ($alter_list as $alter) + { + $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); + } } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php index 4ee48205c8..8bf6c10e2d 100644 --- a/phpBB/phpbb/template/context.php +++ b/phpBB/phpbb/template/context.php @@ -365,15 +365,15 @@ class context if ($mode == 'insert') { // Make sure we are not exceeding the last iteration - if ($key >= sizeof($this->tpldata[$blockname])) + if ($key >= sizeof($block)) { - $key = sizeof($this->tpldata[$blockname]); - unset($this->tpldata[$blockname][($key - 1)]['S_LAST_ROW']); + $key = sizeof($block); + unset($block[($key - 1)]['S_LAST_ROW']); $vararray['S_LAST_ROW'] = true; } else if ($key === 0) { - unset($this->tpldata[$blockname][0]['S_FIRST_ROW']); + unset($block[0]['S_FIRST_ROW']); $vararray['S_FIRST_ROW'] = true; } diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index 3a983491b9..d5b14129b5 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -169,8 +169,7 @@ class extension extends \Twig_Extension $args = func_get_args(); $key = $args[0]; - $context = $this->context->get_data_ref(); - $context_vars = $context['.'][0]; + $context_vars = $this->context->get_root_ref(); if (isset($context_vars['L_' . $key])) { diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index a1e66ba8fe..135d390584 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -201,6 +201,49 @@ class version_helper } /** + * Gets the latest update for the current 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_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; + + // Filter out any versions less than to the current version + $versions = array_filter($versions, function($data) use ($self, $current_version) { + return $self->compare($data['current'], $current_version, '>='); + }); + + // Get the lowest 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/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 99f3108fad..d779008f80 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -57,7 +57,7 @@ function marklist(id, name, state) { jQuery('#' + id + ' input[type=checkbox][name]').each(function() { var $this = jQuery(this); - if ($this.attr('name').substr(0, name.length) === name) { + if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) { $this.prop('checked', state); } }); diff --git a/phpBB/styles/prosilver/template/memberlist_team.html b/phpBB/styles/prosilver/template/memberlist_team.html index b7f2d66d94..327dde412e 100644 --- a/phpBB/styles/prosilver/template/memberlist_team.html +++ b/phpBB/styles/prosilver/template/memberlist_team.html @@ -19,7 +19,7 @@ <tbody> <!-- BEGIN user --> <tr class="<!-- IF group.user.S_ROW_COUNT is even -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF group.user.S_INACTIVE --> inactive<!-- ENDIF -->"> - <td><!-- IF group.user.RANK_IMG --><span class="rank-img">{group.user.RANK_IMG}</span><!-- ELSE --><span class="rank-img">{group.user.RANK_TITLE}</span><!-- ENDIF -->{group.user.USERNAME_FULL}<!-- IF group.user.S_INACTIVE --> ({L_INACTIVE})<!-- ENDIF --></td> + <td><!-- IF group.user.RANK_IMG --><span class="rank-img">{group.user.RANK_IMG}</span><!-- ELSE --><span class="rank-img">{group.user.RANK_TITLE}</span><!-- ENDIF --><!-- EVENT memberlist_team_username_prepend -->{group.user.USERNAME_FULL}<!-- IF group.user.S_INACTIVE --> ({L_INACTIVE})<!-- ENDIF --><!-- EVENT memberlist_team_username_append --></td> <td class="info"><!-- IF group.user.U_GROUP --> <a<!-- IF group.user.GROUP_COLOR --> style="font-weight: bold; color: #{group.user.GROUP_COLOR}"<!-- ENDIF --> href="{group.user.U_GROUP}">{group.user.GROUP_NAME}</a> <!-- ELSE --> diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index b6c454bf05..4365482314 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -76,6 +76,7 @@ <!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --><a href="{searchresults.U_MCP_QUEUE}">{searchresults.UNAPPROVED_IMG}</a> <!-- ENDIF --> <!-- IF searchresults.S_TOPIC_DELETED --><a href="{searchresults.U_MCP_QUEUE}">{DELETED_IMG}</a> <!-- ENDIF --> <!-- IF searchresults.S_TOPIC_REPORTED --><a href="{searchresults.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br /> + <!-- EVENT topiclist_row_topic_title_after --> <!-- IF .searchresults.pagination --> <div class="pagination"> <ul> @@ -91,7 +92,6 @@ </div> <!-- ENDIF --> <!-- IF searchresults.S_HAS_POLL -->{POLL_IMG} <!-- ENDIF --> - <!-- EVENT topiclist_row_topic_title_after --> {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} » {L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a> <!-- EVENT topiclist_row_append --> diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index e7c0e177a6..dfb91891fa 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -493,6 +493,8 @@ blockquote.uncited { padding: 3px; border: 1px solid transparent; font-size: 1em; + overflow-x: scroll; + word-wrap: normal; } .codebox p { diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index 2096062607..5a4c430cd2 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -54,7 +54,7 @@ for (var r = 0; r < rb.length; r++) { - if (rb[r].name.substr(0, name.length) == name) + if (rb[r].name.substr(0, name.length) == name && rb[r].disabled !== true) { rb[r].checked = state; } diff --git a/phpBB/styles/subsilver2/template/memberlist_team.html b/phpBB/styles/subsilver2/template/memberlist_team.html index 18995b6e50..75fade184c 100644 --- a/phpBB/styles/subsilver2/template/memberlist_team.html +++ b/phpBB/styles/subsilver2/template/memberlist_team.html @@ -17,7 +17,7 @@ <!-- BEGIN user --> <!-- IF group.user.S_ROW_COUNT is even --><tr class="row2"><!-- ELSE --><tr class="row1"><!-- ENDIF --> - <td class="gen" align="center"><strong>{group.user.USERNAME_FULL}</strong><!-- IF group.user.S_INACTIVE --> <em>({L_INACTIVE})</em><!-- ENDIF --></td> + <td class="gen" align="center"><!-- EVENT memberlist_team_username_prepend --><strong>{group.user.USERNAME_FULL}</strong><!-- IF group.user.S_INACTIVE --> <em>({L_INACTIVE})</em><!-- ENDIF --><!-- EVENT memberlist_team_username_append --></td> <!-- IF S_DISPLAY_MODERATOR_FORUMS --><td class="gensmall" align="center"><!-- IF group.user.FORUM_OPTIONS --><select style="width: 100%;">{group.user.FORUMS}</select><!-- ELSEIF group.user.FORUMS -->{group.user.FORUMS}<!-- ELSE -->-<!-- ENDIF --></td><!-- ENDIF --> <td class="gensmall" align="center" nowrap="nowrap"> <!-- IF group.user.U_GROUP --> diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index a4185785e3..ae3d48215e 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -83,7 +83,7 @@ function marklist(id, name, state) for (var r = 0; r < rb.length; r++) { - if (rb[r].name.substr(0, name.length) == name) + if (rb[r].name.substr(0, name.length) == name && rb[r].disabled !== true) { rb[r].checked = state; } diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index e0cc9ba512..69b480574e 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -782,9 +782,11 @@ $topic_tracking_info = $tracking_topics = array(); * @var array topic_list Array with current viewforum page topic ids * @var array rowset Array with topics data (in topic_id => topic_data format) * @var int total_topic_count Forum's total topic count +* @var int forum_id Forum identifier * @since 3.1.0-b3 +* @changed 3.1.11-RC1 Added forum_id */ -$vars = array('topic_list', 'rowset', 'total_topic_count'); +$vars = array('topic_list', 'rowset', 'total_topic_count', 'forum_id'); extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topics_data', compact($vars))); // Okay, lets dump out the page ... diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 4ae6017989..1a7eb4698c 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -53,7 +53,7 @@ namespace $this->assertTrue($container->isFrozen()); // Checks inject_config - $this->assertTrue($container->hasParameter('dbal.dbhost')); + $this->assertTrue($container->hasParameter('core.table_prefix')); // Checks use_extensions $this->assertTrue($container->hasParameter('enabled')); diff --git a/tests/di/fixtures/config/services.yml b/tests/di/fixtures/config/services.yml index f2a22ae109..913a2603c9 100644 --- a/tests/di/fixtures/config/services.yml +++ b/tests/di/fixtures/config/services.yml @@ -10,5 +10,8 @@ services: arguments: - @service_container + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/services.yml b/tests/di/fixtures/other_config/services.yml index c299bfc648..d6246d3bc0 100644 --- a/tests/di/fixtures/other_config/services.yml +++ b/tests/di/fixtures/other_config/services.yml @@ -10,5 +10,8 @@ services: arguments: - @service_container + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php new file mode 100644 index 0000000000..c980dfd3d7 --- /dev/null +++ b/tests/feed/attachments_base_test.php @@ -0,0 +1,94 @@ +<?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. + * + */ + +require_once(dirname(__FILE__) . '/attachments_mock_feed.php'); + +class phpbb_feed_attachments_base_test extends phpbb_database_test_case +{ + protected $filesystem; + + /** @var \phpbb_feed_attachments_mock_feed */ + protected $attachments_mocks_feed; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/../extension/fixtures/extensions.xml'); + } + + public function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->filesystem = new \phpbb\filesystem(); + $config = new \phpbb\config\config(array()); + $user = new \phpbb\user('\phpbb\datetime'); + $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx); + $db = $this->new_dbal(); + $cache = new \phpbb_mock_cache(); + $auth = new \phpbb\auth\auth(); + $content_visibility = new \phpbb\content_visibility( + $auth, + $config, + new \phpbb_mock_event_dispatcher(), + $db, + $user, + $phpbb_root_path, + $phpEx, + FORUMS_TABLE, + POSTS_TABLE, + TOPICS_TABLE, + USERS_TABLE + ); + + $this->attachments_mocks_feed = new \phpbb_feed_attachments_mock_feed( + $feed_helper, + $config, + $db, + $cache, + $user, + $auth, + $content_visibility, + new \phpbb_mock_event_dispatcher(), + $phpEx + ); + } + + public function data_fetch_attachments() + { + return array( + array(array(0), array(0)), + array(array(), array(1)), + array(array(), array(), 'RuntimeException') + ); + } + + /** + * @dataProvider data_fetch_attachments + */ + public function test_fetch_attachments($post_ids, $topic_ids, $expected_exception = false) + { + $this->attachments_mocks_feed->post_ids = $post_ids; + $this->attachments_mocks_feed->topic_ids = $topic_ids; + + if ($expected_exception !== false) + { + $this->setExpectedException($expected_exception); + + $this->attachments_mocks_feed->get_sql(); + } + else + { + $this->assertTrue($this->attachments_mocks_feed->get_sql()); + } + } +} diff --git a/tests/feed/attachments_mock_feed.php b/tests/feed/attachments_mock_feed.php new file mode 100644 index 0000000000..0e623fed24 --- /dev/null +++ b/tests/feed/attachments_mock_feed.php @@ -0,0 +1,31 @@ +<?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. + * + */ + +/** + * Board wide feed (aka overall feed) + * + * This will give you the newest {$this->num_items} posts + * from the whole board. + */ +class phpbb_feed_attachments_mock_feed extends \phpbb\feed\attachments_base +{ + public $topic_ids = array(); + public $post_ids = array(); + + function get_sql() + { + parent::fetch_attachments($this->post_ids, $this->topic_ids); + + return true; + } +} diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 528f1602d6..54237f2059 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -332,4 +332,204 @@ class phpbb_version_helper_test extends phpbb_test_case $this->assertSame($expected, $version_helper->get_latest_on_current_branch()); } + + public function get_update_on_branch_data() + { + return array( + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + ), + ), + array( + '1.0.1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array(), + ), + array( + '1.0.1-a1', + array( + '1.0' => array( + 'current' => '1.0.1-a2', + ), + '1.1' => array( + 'current' => '1.1.0', + ), + ), + array( + 'current' => '1.0.1-a2', + ), + ), + array( + '1.1.0', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + array( + '1.1.1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array(), + ), + array( + '1.1.0-a1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.0-a2', + ), + ), + array( + 'current' => '1.1.0-a2', + ), + ), + array( + '1.1.0', + array(), + array(), + ), + // Latest safe release is 1.0.1 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + 'security' => '1.0.1', + ), + ), + // Latest safe release is 1.0.0 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.0.0', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + 'security' => '1.0.0', + ), + ), + // Latest safe release is 1.1.0 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.1.0', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + // Latest 1.0 release is EOL + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'eol' => true, + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + // All are EOL -- somewhat undefined behavior + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'eol' => true, + ), + '1.1' => array( + 'current' => '1.1.1', + 'eol' => true, + ), + ), + array(), + ), + ); + } + + /** + * @dataProvider get_update_on_branch_data + */ + public function test_get_update_on_branch($current_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' => $current_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)); + + $this->assertSame($expected, $version_helper->get_update_on_branch()); + } } |