diff options
-rw-r--r-- | phpBB/adm/style/admin.css | 1 | ||||
-rw-r--r-- | phpBB/assets/javascript/core.js | 1 | ||||
-rwxr-xr-x | phpBB/bin/phpbbcli.php | 5 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_logs.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 38 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 2 | ||||
-rw-r--r-- | phpBB/language/en/common.php | 4 | ||||
-rw-r--r-- | phpBB/language/en/help/faq.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/db/migrator.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/event/php_exporter.php | 25 | ||||
-rw-r--r-- | phpBB/phpbb/filesystem/filesystem.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/session.php | 8 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/navbar_header.html | 12 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/overall_footer.html | 33 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/common.css | 13 | ||||
-rw-r--r-- | phpBB/styles/prosilver/theme/responsive.css | 1 | ||||
-rw-r--r-- | phpBB/viewforum.php | 2 | ||||
-rw-r--r-- | tests/event/fixtures/extra_description.test | 2 | ||||
-rw-r--r-- | tests/event/php_exporter_test.php | 2 | ||||
-rw-r--r-- | tests/migrator/get_callable_from_step_test.php | 136 |
20 files changed, 262 insertions, 33 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 270d513a26..292036d5a8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -66,27 +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 +* @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(bin2hex(random_bytes($num_chars)), 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 +* @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 = bin2hex(random_bytes($num_chars)); + $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 @@ -2467,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, @@ -2475,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, @@ -2484,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']); @@ -4408,6 +4433,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$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/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/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/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/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/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/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..2c2094cba8 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}"> @@ -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/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/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)); + } +} |