From e7e0ab9d0b33121e38a236879fcca417072140f6 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Mon, 17 May 2010 12:12:00 -0500 Subject: [PATCH 001/666] [feature/prune-users] Rework user_delete() functions_user.php user_delete now uses fewer queries to delete a set of users of size > 1 by accepting an array of users rather than a single user at a time. This required changing the third parameter, however the function retains its former behavior with the old-style parameters. PHPBB3-9622 --- phpBB/includes/acp/acp_inactive.php | 5 +- phpBB/includes/acp/acp_prune.php | 5 +- phpBB/includes/functions_user.php | 279 +++++++++++++++------------- 3 files changed, 156 insertions(+), 133 deletions(-) diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index e4fb695a11..833727084f 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -157,10 +157,7 @@ class acp_inactive trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - foreach ($mark as $user_id) - { - user_delete('retain', $user_id, $user_affected[$user_id]); - } + user_delete('retain', $mark, true); add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected)); } diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 6120c15d68..99bec29d6d 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -265,10 +265,7 @@ class acp_prune } else { - foreach ($user_ids as $user_id) - { - user_delete('retain', $user_id, $usernames[$user_id]); - } + user_delete('retain', $user_ids, true); $l_log = 'LOG_PRUNE_USER_DEL_ANON'; } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 317578cd54..0886e8aabf 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -330,20 +330,32 @@ function user_add($user_row, $cp_data = false) /** * Remove User +* @param $mode Either 'retain' or 'remove' */ -function user_delete($mode, $user_id, $post_username = false) +function user_delete($mode, $user_ids, $retain_username = true) { global $cache, $config, $db, $user, $auth; global $phpbb_root_path, $phpEx; + $db->sql_transaction('begin'); + + $user_rows = array(); + if (!is_array($user_ids)) + { + $user_ids = array($user_ids); + } + $sql = 'SELECT * FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user_id; + WHERE ' . $db->sql_in_set('user_id', $user_ids); $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); + while ($row = $db->sql_fetchrow($result)) + { + $user_rows[$row['user_id']] = $row; + } $db->sql_freeresult($result); - if (!$user_row) + if (!$user_rows) { return false; } @@ -351,7 +363,8 @@ function user_delete($mode, $user_id, $post_username = false) // Before we begin, we will remove the reports the user issued. $sql = 'SELECT r.post_id, p.topic_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p - WHERE r.user_id = ' . $user_id . ' + WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . //r.user_id = ' . $user_id . ' + ' AND p.post_id = r.post_id'; $result = $db->sql_query($sql); @@ -405,135 +418,157 @@ function user_delete($mode, $user_id, $post_username = false) } // Remove reports - $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE user_id = ' . $user_id); + $db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $user_ids)); - if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == AVATAR_UPLOAD) + // Some things need to be done in the loop (if the query changes based + // on which user is currently being deleted) + $added_guest_posts = 0; + foreach ($user_rows as $user_id => $user_row) { - avatar_delete('user', $user_row); + if ($user_row['user_avatar'] && $user_row['user_avatar_type'] == AVATAR_UPLOAD) + { + avatar_delete('user', $user_row); + } + + // Decrement number of users if this user is active + if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) + { + set_config_count('num_users', -1, true); + } + + switch ($mode) + { + case 'retain': + if ($retain_username === false) + { + $post_username = $user->lang['GUEST']; + } + else + { + $post_username = $user_row['username']; + } + + // If the user is inactive and newly registered we assume no posts from the user, and save the queries + if ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_REGISTER && !$user_row['user_posts']) + { + } + else + { + // When we delete these users and retain the posts, we must assign all the data to the guest user + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = '' + WHERE forum_last_poster_id = $user_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "' + WHERE poster_id = $user_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = '' + WHERE topic_poster = $user_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = '' + WHERE topic_last_poster_id = $user_id"; + $db->sql_query($sql); + + // Since we change every post by this author, we need to count this amount towards the anonymous user + + if ($user_row['user_posts']) + { + $added_guest_posts += $user_row['user_posts']; + } + } + break; + + case 'remove': + // there is nothing variant specific to deleting posts + break; + } } - switch ($mode) + // Now do the invariant tasks + // all queries performed in one call of this function are in a single transaction + // so this is kosher + if ($mode == 'retain') { - case 'retain': + // Assign more data to the Anonymous user + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' + SET poster_id = ' . ANONYMOUS . ' + WHERE ' . $db->sql_in_set('poster_id', $user_ids); + $db->sql_query($sql); - $db->sql_transaction('begin'); + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_edit_user = ' . ANONYMOUS . ' + WHERE ' . $db->sql_in_set('post_edit_user', $user_ids); + $db->sql_query($sql); - if ($post_username === false) - { - $post_username = $user->lang['GUEST']; - } + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_posts = user_posts + ' . $added_guest_posts . ' + WHERE user_id = ' . ANONYMOUS; + $db->sql_query($sql); + } + else if ($mode == 'remove') + { + if (!function_exists('delete_posts')) + { + include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + } - // If the user is inactive and newly registered we assume no posts from this user being there... - if ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_REGISTER && !$user_row['user_posts']) - { - } - else - { - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = '' - WHERE forum_last_poster_id = $user_id"; - $db->sql_query($sql); + // Find any topics whose only posts are being deleted, and remove them from the topics table + $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts + FROM ' . POSTS_TABLE . ' + WHERE ' . $db->sql_in_set('poster_id', $user_ids) . ' + GROUP BY topic_id'; + $result = $db->sql_query($sql); - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "' - WHERE poster_id = $user_id"; - $db->sql_query($sql); + $topic_id_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_id_ary[$row['topic_id']] = $row['total_posts']; + } + $db->sql_freeresult($result); - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_edit_user = ' . ANONYMOUS . " - WHERE post_edit_user = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = '' - WHERE topic_poster = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = '' - WHERE topic_last_poster_id = $user_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . " - WHERE poster_id = $user_id"; - $db->sql_query($sql); - - // Since we change every post by this author, we need to count this amount towards the anonymous user - - // Update the post count for the anonymous user - if ($user_row['user_posts']) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $user_row['user_posts'] . ' - WHERE user_id = ' . ANONYMOUS; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - break; - - case 'remove': - - if (!function_exists('delete_posts')) - { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - } - - $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts - FROM ' . POSTS_TABLE . " - WHERE poster_id = $user_id - GROUP BY topic_id"; + if (sizeof($topic_id_ary)) + { + $sql = 'SELECT topic_id, topic_replies, topic_replies_real + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); $result = $db->sql_query($sql); - $topic_id_ary = array(); + $del_topic_ary = array(); while ($row = $db->sql_fetchrow($result)) { - $topic_id_ary[$row['topic_id']] = $row['total_posts']; + if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) + { + $del_topic_ary[] = $row['topic_id']; + } } $db->sql_freeresult($result); - if (sizeof($topic_id_ary)) + if (sizeof($del_topic_ary)) { - $sql = 'SELECT topic_id, topic_replies, topic_replies_real - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); - $result = $db->sql_query($sql); - - $del_topic_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) - { - $del_topic_ary[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (sizeof($del_topic_ary)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary); - $db->sql_query($sql); - } + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary); + $db->sql_query($sql); } + } - // Delete posts, attachments, etc. - delete_posts('poster_id', $user_id); - - break; + // actually do the meat of the work if we are deleting all the users' posts + // delete_posts can handle any number of IDs in its second argument + delete_posts('poster_id', $user_ids); } - $db->sql_transaction('begin'); - $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE, PRIVMSGS_FOLDER_TABLE, PRIVMSGS_RULES_TABLE); + // Delete the miscellaneous (non-post) data for the user foreach ($table_ary as $table) { $sql = "DELETE FROM $table - WHERE user_id = $user_id"; + WHERE " . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); } @@ -541,35 +576,35 @@ function user_delete($mode, $user_id, $post_username = false) // Delete user log entries about this user $sql = 'DELETE FROM ' . LOG_TABLE . ' - WHERE reportee_id = ' . $user_id; + WHERE ' . $db->sql_in_set('user_id', $user_ids); //reportee_id = ' . $user_id; $db->sql_query($sql); // Change user_id to anonymous for this users triggered events $sql = 'UPDATE ' . LOG_TABLE . ' SET user_id = ' . ANONYMOUS . ' - WHERE user_id = ' . $user_id; + WHERE ' . $db->sql_in_set('user_id', $user_ids); //user_id = ' . $user_id; $db->sql_query($sql); // Delete the user_id from the zebra table $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user_id . ' - OR zebra_id = ' . $user_id; + WHERE ' . $db->sql_in_set('user_id', $user_ids) . //user_id = ' . $user_id . ' + ' OR ' . $db->sql_in_set('zebra_id', $user_ids); $db->sql_query($sql); // Delete the user_id from the banlist $sql = 'DELETE FROM ' . BANLIST_TABLE . ' - WHERE ban_userid = ' . $user_id; + WHERE ' . $db->sql_in_set('ban_userid', $user_ids); $db->sql_query($sql); // Delete the user_id from the session table $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' - WHERE session_user_id = ' . $user_id; + WHERE ' . $db->sql_in_set('session_user_id', $user_ids); $db->sql_query($sql); // Remove any undelivered mails... $sql = 'SELECT msg_id, user_id FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE author_id = ' . $user_id . ' + WHERE ' . $db->sql_in_set('author_id', $user_ids) . ' AND folder_id = ' . PRIVMSGS_NO_BOX; $result = $db->sql_query($sql); @@ -589,24 +624,24 @@ function user_delete($mode, $user_id, $post_username = false) } $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE author_id = ' . $user_id . ' + WHERE ' . $db->sql_in_set('author_id', $user_id) . ' AND folder_id = ' . PRIVMSGS_NO_BOX; $db->sql_query($sql); // Delete all to-information $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE user_id = ' . $user_id; + WHERE ' . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); // Set the remaining author id to anonymous - this way users are still able to read messages from users being removed $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' SET author_id = ' . ANONYMOUS . ' - WHERE author_id = ' . $user_id; + WHERE ' . $db->sql_in_set('author_id', $user_ids); $db->sql_query($sql); $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' SET author_id = ' . ANONYMOUS . ' - WHERE author_id = ' . $user_id; + WHERE ' . $db->sql_in_set('author_id', $user_id); $db->sql_query($sql); foreach ($undelivered_user as $_user_id => $ary) @@ -626,17 +661,11 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); // Reset newest user info if appropriate - if ($config['newest_user_id'] == $user_id) + if (in_array($config['newest_user_id'], $user_ids)) { update_last_username(); } - // Decrement number of users if this user is active - if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE) - { - set_config_count('num_users', -1, true); - } - return false; } From 04a6303527d9bf29114b51001d06af5235ea0847 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 8 May 2011 03:01:38 -0400 Subject: [PATCH 002/666] [feature/prune-users] Apply e6ed55a9c1ceb07ab2e87d4a53f9e688fda319c5. This was done in PHPBB3-9872. PHPBB3-9622 --- phpBB/includes/functions_user.php | 41 +------------------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0886e8aabf..9b16a56b1c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -518,46 +518,7 @@ function user_delete($mode, $user_ids, $retain_username = true) include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } - // Find any topics whose only posts are being deleted, and remove them from the topics table - $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts - FROM ' . POSTS_TABLE . ' - WHERE ' . $db->sql_in_set('poster_id', $user_ids) . ' - GROUP BY topic_id'; - $result = $db->sql_query($sql); - - $topic_id_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_id_ary[$row['topic_id']] = $row['total_posts']; - } - $db->sql_freeresult($result); - - if (sizeof($topic_id_ary)) - { - $sql = 'SELECT topic_id, topic_replies, topic_replies_real - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary)); - $result = $db->sql_query($sql); - - $del_topic_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) - { - $del_topic_ary[] = $row['topic_id']; - } - } - $db->sql_freeresult($result); - - if (sizeof($del_topic_ary)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary); - $db->sql_query($sql); - } - } - - // actually do the meat of the work if we are deleting all the users' posts + // Delete posts, attachments, etc. // delete_posts can handle any number of IDs in its second argument delete_posts('poster_id', $user_ids); } From fe347ec1124de7022bbbf37d0a1fffeff56c7271 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Tue, 25 May 2010 10:52:01 -0500 Subject: [PATCH 003/666] [feature/prune-users] Adjust some language strings for new features Adjust two language strings for ACP prune feature to include descriptions for new features. PHPBB3-9622 --- phpBB/adm/style/acp_prune_users.html | 27 ++++- phpBB/adm/style/confirm_body_prune.html | 28 +++-- phpBB/includes/acp/acp_prune.php | 139 +++++++++++++++++++----- phpBB/language/en/acp/prune.php | 14 ++- 4 files changed, 162 insertions(+), 46 deletions(-) diff --git a/phpBB/adm/style/acp_prune_users.html b/phpBB/adm/style/acp_prune_users.html index 0f2b23dcef..a6c5679a11 100644 --- a/phpBB/adm/style/acp_prune_users.html +++ b/phpBB/adm/style/acp_prune_users.html @@ -9,7 +9,7 @@
- {L_ACP_PRUNE_USERS} + {L_CRITERIA}
@@ -18,9 +18,16 @@
+
+
+
+

{L_JOINED_EXPLAIN}
-
+
+ {L_AFTER} +

{L_BEFORE} +

{L_LAST_ACTIVE_EXPLAIN}
@@ -30,11 +37,27 @@
+
+
+
+
+
+

{L_PRUNE_USERS_GROUP_EXPLAIN}
+
+
+
+ +
+ {L_USERNAMES}

{L_SELECT_USERS_EXPLAIN}
[ {L_FIND_USERNAME} ]
+
+ +
+ {L_OPTIONS}

{L_DELETE_USER_POSTS_EXPLAIN}
diff --git a/phpBB/adm/style/confirm_body_prune.html b/phpBB/adm/style/confirm_body_prune.html index 9481386231..92e0a22e71 100644 --- a/phpBB/adm/style/confirm_body_prune.html +++ b/phpBB/adm/style/confirm_body_prune.html @@ -2,6 +2,23 @@ +
+

{L_PRUNE_USERS_LIST}

+

{L_PRUNE_USERS_LIST_DEACTIVATE}

{L_PRUNE_USERS_LIST_DELETE}

+ +
+ + » + {users.USERNAME} + [{L_USER_ADMIN}]
+ +
+ + {L_MARK_ALL} • + {L_UNMARK_ALL} + +
+

{MESSAGE_TITLE}

{MESSAGE_TEXT}

@@ -12,17 +29,6 @@   - -

{L_PRUNE_USERS_LIST}

-

{L_PRUNE_USERS_LIST_DEACTIVATE}

{L_PRUNE_USERS_LIST_DELETE}

- -
- - » {users.USERNAME} [{L_USER_ADMIN}]
- - -

-
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 99bec29d6d..a21805972f 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -243,6 +243,7 @@ class acp_prune if (confirm_box(true)) { $user_ids = $usernames = array(); + $this->get_prune_users($user_ids, $usernames); if (sizeof($user_ids)) @@ -256,10 +257,7 @@ class acp_prune { if ($deleteposts) { - foreach ($user_ids as $user_id) - { - user_delete('remove', $user_id); - } + user_delete('remove', $user_ids); $l_log = 'LOG_PRUNE_USER_DEL_DEL'; } @@ -297,6 +295,7 @@ class acp_prune { $template->assign_block_vars('users', array( 'USERNAME' => $usernames[$user_id], + 'USER_ID' => $user_id, 'U_PROFILE' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx, 'mode=viewprofile&u=' . $user_id), 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', )); @@ -312,8 +311,8 @@ class acp_prune 'mode' => $mode, 'prune' => 1, - 'users' => utf8_normalize_nfc(request_var('users', '', true)), - 'username' => utf8_normalize_nfc(request_var('username', '', true)), + 'users' => request_var('users', '', true), + 'username' => request_var('username', '', true), 'email' => request_var('email', ''), 'joined_select' => request_var('joined_select', ''), 'joined' => request_var('joined', ''), @@ -338,22 +337,27 @@ class acp_prune } $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); - $s_find_join_time = ''; - foreach ($find_time as $key => $value) - { - $s_find_join_time .= ''; - } - $s_find_active_time = ''; foreach ($find_time as $key => $value) { $s_find_active_time .= ''; } + $s_group_list = ''; + $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' + WHERE group_type <> ' . GROUP_SPECIAL . ' + ORDER BY group_name ASC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $s_group_list .= '
+

{L_PRUNE_USERS_GROUP_EXPLAIN}
+
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index a21805972f..b10eb292d2 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -245,7 +245,6 @@ class acp_prune $user_ids = $usernames = array(); $this->get_prune_users($user_ids, $usernames); - if (sizeof($user_ids)) { if ($action == 'deactivate') @@ -311,17 +310,7 @@ class acp_prune 'mode' => $mode, 'prune' => 1, - 'users' => request_var('users', '', true), - 'username' => request_var('username', '', true), - 'email' => request_var('email', ''), - 'joined_select' => request_var('joined_select', ''), - 'joined' => request_var('joined', ''), - 'active_select' => request_var('active_select', ''), - 'active' => request_var('active', ''), - 'count_select' => request_var('count_select', ''), - 'count' => request_var('count', ''), 'deleteposts' => request_var('deleteposts', 0), - 'action' => request_var('action', ''), )), 'confirm_body_prune.html'); } @@ -343,7 +332,7 @@ class acp_prune $s_find_active_time .= ''; } - $s_group_list = ''; + $s_group_list = ''; $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE group_type <> ' . GROUP_SPECIAL . ' ORDER BY group_name ASC'; @@ -372,6 +361,8 @@ class acp_prune $users_by_name = request_var('users', '', true); $users_by_id = request_var('user_ids', array(0)); + $group_id = request_var('group_id', 0); + $posts_on_queue = request_var('posts_on_queue', 0); if ($users_by_name) { @@ -399,7 +390,6 @@ class acp_prune $active = request_var('active', ''); $count = request_var('count', 0); - $posts_on_queue = request_var('posts_on_queue', 0); $active = ($active) ? explode('-', $active) : array(); $joined_before = ($joined_before) ? explode('-', $joined_before) : array(); @@ -424,7 +414,7 @@ class acp_prune } else if (empty($joined_after) && !empty($joined_before)) { - $joined_sql = ' AND user_regdate < ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[3]); + $joined_sql = ' AND user_regdate < ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); } // implicit else when both arrays are empty do nothing From 9915ed52551b9b11e2cfcadabcb758ab05c6db6b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 16:07:14 +0100 Subject: [PATCH 012/666] =?UTF-8?q?[ticket/8743]=20Include=20poster=C2=B4s?= =?UTF-8?q?=20name=20in=20mail=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPBB3-8743 --- phpBB/includes/functions_posting.php | 6 ++++-- phpBB/language/en/email/forum_notify.txt | 2 +- phpBB/language/en/email/newtopic_notify.txt | 2 +- phpBB/language/en/email/topic_notify.txt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 77d92e26e2..be3aa844fe 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1160,7 +1160,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id /** * User Notification */ -function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) +function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id, $author_name = '') { global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; @@ -1323,6 +1323,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id 'USERNAME' => htmlspecialchars_decode($addr['name']), 'TOPIC_TITLE' => htmlspecialchars_decode($topic_title), 'FORUM_NAME' => htmlspecialchars_decode($forum_name), + 'AUTHOR_NAME' => htmlspecialchars_decode($author_name), 'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id", 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id", @@ -2585,7 +2586,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Send Notifications if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { - user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']); + $username = ($username) ? $username : $user->data['username']; + user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username); } $params = $add_anchor = ''; diff --git a/phpBB/language/en/email/forum_notify.txt b/phpBB/language/en/email/forum_notify.txt index fae5a83885..490780a0a6 100644 --- a/phpBB/language/en/email/forum_notify.txt +++ b/phpBB/language/en/email/forum_notify.txt @@ -2,7 +2,7 @@ Subject: Forum post notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" by {AUTHOR_NAME} since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic. {U_NEWEST_POST} diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt index 529bbf0f8f..eda1370938 100644 --- a/phpBB/language/en/email/newtopic_notify.txt +++ b/phpBB/language/en/email/newtopic_notify.txt @@ -2,7 +2,7 @@ Subject: New topic notification - "{FORUM_NAME}" Hello {USERNAME}, -You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. +You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic by {AUTHOR_NAME} since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum. {U_FORUM} diff --git a/phpBB/language/en/email/topic_notify.txt b/phpBB/language/en/email/topic_notify.txt index 99587b28e0..fcfbcc2abd 100644 --- a/phpBB/language/en/email/topic_notify.txt +++ b/phpBB/language/en/email/topic_notify.txt @@ -2,7 +2,7 @@ Subject: Topic reply notification - "{TOPIC_TITLE}" Hello {USERNAME}, -You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. +You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply by {AUTHOR_NAME} since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic. If you want to view the newest post made since your last visit, click the following link: {U_NEWEST_POST} From 15d2f294c664e11fb1f2bc84238067cf71a544e6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 25 Mar 2012 20:56:00 -0400 Subject: [PATCH 013/666] [feature/prune-users] Cosmetic changes per bantu's review. PHPBB3-9622 --- phpBB/includes/acp/acp_prune.php | 5 +++-- phpBB/includes/functions_user.php | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index b10eb292d2..145c0c3854 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -333,7 +333,8 @@ class acp_prune } $s_group_list = ''; - $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' + $sql = 'SELECT group_id, group_name + FROM ' . GROUPS_TABLE . ' WHERE group_type <> ' . GROUP_SPECIAL . ' ORDER BY group_name ASC'; $result = $db->sql_query($sql); @@ -403,7 +404,7 @@ class acp_prune // so that our time range is a full day instead of 1 second if ($joined_after == $joined_before) { - $joined_after[2] += 1; //$joined_after[2]++; + $joined_after[2] += 1; } $joined_sql = ' AND user_regdate BETWEEN ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]) . ' AND ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index e9655ba736..c78949342b 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -365,8 +365,7 @@ function user_delete($mode, $user_ids, $retain_username = true) // Before we begin, we will remove the reports the user issued. $sql = 'SELECT r.post_id, p.topic_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p - WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . //r.user_id = ' . $user_id . ' - ' + WHERE ' . $db->sql_in_set('r.user_id', $user_ids) . ' AND p.post_id = r.post_id'; $result = $db->sql_query($sql); @@ -554,13 +553,13 @@ function user_delete($mode, $user_ids, $retain_username = true) // Change user_id to anonymous for this users triggered events $sql = 'UPDATE ' . LOG_TABLE . ' SET user_id = ' . ANONYMOUS . ' - WHERE ' . $user_id_sql; //user_id = ' . $user_id; + WHERE ' . $user_id_sql; $db->sql_query($sql); // Delete the user_id from the zebra table $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' - WHERE ' . $user_id_sql . //user_id = ' . $user_id . ' - ' OR ' . $db->sql_in_set('zebra_id', $user_ids); + WHERE ' . $user_id_sql . ' + OR ' . $db->sql_in_set('zebra_id', $user_ids); $db->sql_query($sql); // Delete the user_id from the banlist From 8e2cbe39cdd7672638dbc0d6a0f65a7365db0d91 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 04:06:52 +0200 Subject: [PATCH 014/666] [feature/dic] Convert common.php to Symfony2 DependencyInjection component PHPBB3-10739 --- phpBB/common.php | 43 +++++++++--------- phpBB/composer.json | 5 ++- phpBB/composer.lock | 16 ++++++- phpBB/config/parameters.yml | 11 +++++ phpBB/config/services.yml | 87 +++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 24 deletions(-) create mode 100644 phpBB/config/parameters.yml create mode 100644 phpBB/config/services.yml diff --git a/phpBB/common.php b/phpBB/common.php index b3b8d7e4f7..aa6115fe1c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -15,6 +15,9 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\EventDispatcher\EventDispatcher; require($phpbb_root_path . 'includes/startup.' . $phpEx); @@ -91,43 +94,41 @@ $phpbb_class_loader_ext->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); $phpbb_class_loader->register(); +$container = new ContainerBuilder(); +$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); +$loader->load('parameters.yml'); +$loader->load('services.yml'); + +$container->setParameter('core.root_path', $phpbb_root_path); +$container->setParameter('core.php_ext', $phpEx); + // set up caching -$cache_factory = new phpbb_cache_factory($acm_type); -$cache = $cache_factory->get_service(); +$cache = $container->get('cache'); $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); -$user = new phpbb_user(); -$auth = new phpbb_auth(); -$db = new $sql_db(); +$phpbb_dispatcher = $container->get('dispatcher'); +$request = $container->get('request'); +$user = $container->get('user'); +$auth = $container->get('auth'); +$db = $container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - // Grab global variables, re-cache if necessary -$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); +$config = $container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions -$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); +$phpbb_extension_manager = $container->get('ext.manager'); -// Initialize style -$phpbb_style_resource_locator = new phpbb_style_resource_locator(); -$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); +$template = $container->get('template'); +$style = $container->get('style'); -$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); $phpbb_subscriber_loader->load(); // Add own hook handler diff --git a/phpBB/composer.json b/phpBB/composer.json index 1059b97f84..56fb2454d1 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -1,5 +1,8 @@ { "require": { - "symfony/event-dispatcher": "2.0.*" + "symfony/config": "2.0.*", + "symfony/dependency-injection": "2.0.*", + "symfony/event-dispatcher": "2.0.*", + "symfony/yaml": "2.0.*" } } diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 062ad4b3aa..1707524da1 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,9 +1,21 @@ { - "hash": "9bada3748ec2933fe0864dcfafbcd671", + "hash": "b1e9c3bcfcee0c5630742abb3e49685f", "packages": [ + { + "package": "symfony/config", + "version": "v2.0.12" + }, + { + "package": "symfony/dependency-injection", + "version": "v2.0.12" + }, { "package": "symfony/event-dispatcher", - "version": "v2.0.10" + "version": "v2.0.12" + }, + { + "package": "symfony/yaml", + "version": "v2.0.12" } ], "aliases": [] diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml new file mode 100644 index 0000000000..8a90c8e99d --- /dev/null +++ b/phpBB/config/parameters.yml @@ -0,0 +1,11 @@ +parameters: + cache.acm_type: file + dbal.driver: dbal_mysqli + dbal.dbhost: + dbal.dbuser: root + dbal.dbpasswd: + dbal.dbname: phpbb_dev + dbal.dbport: + dbal.new_link: false + tables.config: phpbb_config + tables.ext: phpbb_ext diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml new file mode 100644 index 0000000000..2bf8478f82 --- /dev/null +++ b/phpBB/config/services.yml @@ -0,0 +1,87 @@ +services: + cache_factory: + class: phpbb_cache_factory + arguments: + - %cache.acm_type% + + cache: + class: phpbb_cache_service + factory_service: cache_factory + factory_method: get_service + + cache.driver: + class: phpbb_cache_driver_interface + factory_service: cache + factory_method: get_driver + + dispatcher: + class: phpbb_event_dispatcher + + request: + class: phpbb_request + + user: + class: phpbb_user + + auth: + class: phpbb_auth + + dbal.conn: + class: %dbal.driver% + calls: + - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] + + config: + class: phpbb_config_db + arguments: + - @dbal.conn + - @cache.driver + - %tables.config% + + ext.manager: + class: phpbb_extension_manager + arguments: + - @dbal.conn + - %tables.ext% + - %core.root_path% + - .%core.php_ext% + - @cache.driver + + style.resource_locator: + class: phpbb_style_resource_locator + + style.path_provider_ext: + class: phpbb_style_extension_path_provider + arguments: + - @ext.manager + - @style.path_provider + + style.path_provider: + class: phpbb_style_path_provider + + template: + class: phpbb_style_template + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @user + - @style.resource_locator + - @style.path_provider_ext + + style: + class: phpbb_style + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @user + - @style.resource_locator + - @style.path_provider_ext + - @template + + event.subscriber_loader: + class: phpbb_event_extension_subscriber_loader + arguments: + - @dispatcher + - @ext.manager From b12f9a285546641415d9ea2dd9e3a3dba6527d1a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:21:26 +0200 Subject: [PATCH 015/666] [feature/dic] Remove cache factory, now handled by DIC PHPBB3-10739 --- phpBB/config/parameters.yml | 4 +-- phpBB/config/services.yml | 15 ++++-------- phpBB/includes/cache/factory.php | 42 -------------------------------- 3 files changed, 7 insertions(+), 54 deletions(-) delete mode 100644 phpBB/includes/cache/factory.php diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml index 8a90c8e99d..da29ae8417 100644 --- a/phpBB/config/parameters.yml +++ b/phpBB/config/parameters.yml @@ -1,6 +1,6 @@ parameters: - cache.acm_type: file - dbal.driver: dbal_mysqli + cache.driver.class: phpbb_cache_driver_file + dbal.driver.class: dbal_mysqli dbal.dbhost: dbal.dbuser: root dbal.dbpasswd: diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 2bf8478f82..09eb993ca6 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,18 +1,13 @@ services: - cache_factory: - class: phpbb_cache_factory - arguments: - - %cache.acm_type% - cache: class: phpbb_cache_service - factory_service: cache_factory - factory_method: get_service + arguments: + - @cache.driver cache.driver: class: phpbb_cache_driver_interface - factory_service: cache - factory_method: get_driver + arguments: + - %cache.driver.class% dispatcher: class: phpbb_event_dispatcher @@ -27,7 +22,7 @@ services: class: phpbb_auth dbal.conn: - class: %dbal.driver% + class: %dbal.driver.class% calls: - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] diff --git a/phpBB/includes/cache/factory.php b/phpBB/includes/cache/factory.php deleted file mode 100644 index 01c4d0b901..0000000000 --- a/phpBB/includes/cache/factory.php +++ /dev/null @@ -1,42 +0,0 @@ -acm_type = $acm_type; - } - - public function get_driver() - { - $class_name = 'phpbb_cache_driver_' . $this->acm_type; - return new $class_name(); - } - - public function get_service() - { - $driver = $this->get_driver(); - $service = new phpbb_cache_service($driver); - return $service; - } -} From 776160a7e35a1f82325b7acf573906310791c573 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:23:33 +0200 Subject: [PATCH 016/666] [feature/dic] Fetch cache driver explicitly PHPBB3-10739 --- phpBB/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index aa6115fe1c..591969df74 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,8 +104,8 @@ $container->setParameter('core.php_ext', $phpEx); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); +$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); +$phpbb_class_loader->set_cache($container->get('cache.driver')); // Instantiate some basic classes $phpbb_dispatcher = $container->get('dispatcher'); From bca600877cbd92246949366238d365bbc3039d5a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:27:46 +0200 Subject: [PATCH 017/666] [feature/dic] Move cron manager into DIC PHPBB3-10739 --- phpBB/common.php | 2 +- phpBB/config/services.yml | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index 591969df74..0446b5c15e 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -142,5 +142,5 @@ foreach ($cache->obtain_hooks() as $hook) if (!$config['use_system_cron']) { - $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); + $cron = $container->get('cron.manager'); } diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 09eb993ca6..85a230de52 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -80,3 +80,14 @@ services: arguments: - @dispatcher - @ext.manager + + cron.task_provider: + class: phpbb_cron_task_provider + arguments: + - @ext.manager + + cron.manager: + class: phpbb_cron_manager + arguments: + - @cron.task_provider + - @cache.driver From 873630f04e6502cc69e6b208f596414f240bc923 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:45:33 +0200 Subject: [PATCH 018/666] [feature/dic] Move class loader into DIC PHPBB3-10739 --- phpBB/common.php | 17 ++++++++--------- phpBB/config/services.yml | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 0446b5c15e..117dc2051e 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -88,12 +88,6 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -// Setup class loader first -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); -$phpbb_class_loader->register(); - $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); $loader->load('parameters.yml'); @@ -102,6 +96,12 @@ $loader->load('services.yml'); $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); +// Setup class loader first +$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = $container->get('class_loader'); +$phpbb_class_loader->register(); + // set up caching $cache = $container->get('cache'); $phpbb_class_loader_ext->set_cache($container->get('cache.driver')); @@ -124,13 +124,12 @@ set_config_count(null, null, null, $config); // load extensions $phpbb_extension_manager = $container->get('ext.manager'); +$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); +$phpbb_subscriber_loader->load(); $template = $container->get('template'); $style = $container->get('style'); -$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); -$phpbb_subscriber_loader->load(); - // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 85a230de52..ef459f4903 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,13 +1,28 @@ services: + class_loader: + class: phpbb_class_loader + arguments: + - phpbb_ + - %core.root_path%includes/ + - .%core.php_ext% + + class_loader.ext: + class: phpbb_class_loader + arguments: + - phpbb_ext_ + - %core.root_path%ext/ + - .%core.php_ext% + cache: class: phpbb_cache_service arguments: - @cache.driver cache.driver: - class: phpbb_cache_driver_interface - arguments: - - %cache.driver.class% + class: %cache.driver.class% + + cache.driver.install: + class: phpbb_cache_driver_file dispatcher: class: phpbb_event_dispatcher From a7f61b91b7feec80cd9d544502aef937f036ae7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:45:58 +0200 Subject: [PATCH 019/666] [feature/dic] Use DIC in download/file and install/index PHPBB3-10739 --- phpBB/download/file.php | 39 ++++++++++++++++++++++----------------- phpBB/install/index.php | 24 ++++++++++++++++-------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index c01b0789de..bc7042fbc8 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -14,7 +14,6 @@ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); - // Thank you sun. if (isset($_SERVER['CONTENT_TYPE'])) { @@ -45,20 +44,27 @@ if (isset($_GET['avatar'])) require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $loader->load('parameters.yml'); + $loader->load('services.yml'); + + $container->setParameter('core.root_path', $phpbb_root_path); + $container->setParameter('core.php_ext', $phpEx); + + $phpbb_class_loader_ext = $container->get('class_loader.ext'); $phpbb_class_loader_ext->register(); - $phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); + $phpbb_class_loader = $container->get('class_loader'); $phpbb_class_loader->register(); // set up caching - $cache_factory = new phpbb_cache_factory($acm_type); - $cache = $cache_factory->get_service(); - $phpbb_class_loader_ext->set_cache($cache->get_driver()); - $phpbb_class_loader->set_cache($cache->get_driver()); + $cache = $container->get('cache'); + $phpbb_class_loader_ext->set_cache($container->get('cache.driver')); + $phpbb_class_loader->set_cache($container->get('cache.driver')); - $phpbb_dispatcher = new phpbb_event_dispatcher(); - $request = new phpbb_request(); - $db = new $sql_db(); + $phpbb_dispatcher = $container->get('dispatcher'); + $request = $container->get('request'); + $db = $container->get('dbal.conn'); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) @@ -69,19 +75,18 @@ if (isset($_GET['avatar'])) request_var('', 0, false, false, $request); - // worst-case default - $browser = strtolower($request->header('User-Agent', 'msie 6.0')); - - $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); + $config = $container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions - $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); - - $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); + $phpbb_extension_manager = $container->get('ext.manager'); + $phpbb_subscriber_loader = $container->get('event.subscriber_loader'); $phpbb_subscriber_loader->load(); + // worst-case default + $browser = strtolower($request->header('User-Agent', 'msie 6.0')); + $filename = request_var('avatar', ''); $avatar_group = false; $exit = false; diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 13ab30a9fa..36c10c3ca6 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -79,19 +79,27 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); +$container = new ContainerBuilder(); +$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); +$loader->load('parameters.yml'); +$loader->load('services.yml'); + +$container->setParameter('core.root_path', $phpbb_root_path); +$container->setParameter('core.php_ext', $phpEx); +$container->setAlias('cache.driver.install', 'cache.driver'); + +$phpbb_class_loader_ext = $container->get('class_loader.ext'); $phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); +$phpbb_class_loader = $container->get('class_loader'); $phpbb_class_loader->register(); // set up caching -$cache_factory = new phpbb_cache_factory('file'); -$cache = $cache_factory->get_service(); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); +$cache = $container->get('cache'); +$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); +$phpbb_class_loader->set_cache($container->get('cache.driver')); -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); +$phpbb_dispatcher = $container->get('dispatcher'); +$request = $container->get('request'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function From dc9ccc432cd0b24cf762f8285d8a90f52b8efe5b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 21:20:58 +0200 Subject: [PATCH 020/666] [feature/dic] Make use of calls to cut down on boilerplate PHPBB3-10739 --- phpBB/common.php | 7 +------ phpBB/config/services.yml | 8 ++++++++ phpBB/download/file.php | 7 +------ phpBB/install/index.php | 6 +----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 117dc2051e..51478662d7 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -97,15 +97,11 @@ $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); // Setup class loader first -$phpbb_class_loader_ext = $container->get('class_loader.ext'); -$phpbb_class_loader_ext->register(); $phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader->register(); +$phpbb_class_loader_ext = $container->get('class_loader.ext'); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); -$phpbb_class_loader->set_cache($container->get('cache.driver')); // Instantiate some basic classes $phpbb_dispatcher = $container->get('dispatcher'); @@ -125,7 +121,6 @@ set_config_count(null, null, null, $config); // load extensions $phpbb_extension_manager = $container->get('ext.manager'); $phpbb_subscriber_loader = $container->get('event.subscriber_loader'); -$phpbb_subscriber_loader->load(); $template = $container->get('template'); $style = $container->get('style'); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index ef459f4903..6f2ed8c7c3 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -5,6 +5,9 @@ services: - phpbb_ - %core.root_path%includes/ - .%core.php_ext% + calls: + - [register, []] + - [set_cache, [@cache.driver]] class_loader.ext: class: phpbb_class_loader @@ -12,6 +15,9 @@ services: - phpbb_ext_ - %core.root_path%ext/ - .%core.php_ext% + calls: + - [register, []] + - [set_cache, [@cache.driver]] cache: class: phpbb_cache_service @@ -95,6 +101,8 @@ services: arguments: - @dispatcher - @ext.manager + calls: + - [load, []] cron.task_provider: class: phpbb_cron_task_provider diff --git a/phpBB/download/file.php b/phpBB/download/file.php index bc7042fbc8..eabb6edbbb 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -52,15 +52,11 @@ if (isset($_GET['avatar'])) $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); - $phpbb_class_loader_ext = $container->get('class_loader.ext'); - $phpbb_class_loader_ext->register(); $phpbb_class_loader = $container->get('class_loader'); - $phpbb_class_loader->register(); + $phpbb_class_loader_ext = $container->get('class_loader.ext'); // set up caching $cache = $container->get('cache'); - $phpbb_class_loader_ext->set_cache($container->get('cache.driver')); - $phpbb_class_loader->set_cache($container->get('cache.driver')); $phpbb_dispatcher = $container->get('dispatcher'); $request = $container->get('request'); @@ -82,7 +78,6 @@ if (isset($_GET['avatar'])) // load extensions $phpbb_extension_manager = $container->get('ext.manager'); $phpbb_subscriber_loader = $container->get('event.subscriber_loader'); - $phpbb_subscriber_loader->load(); // worst-case default $browser = strtolower($request->header('User-Agent', 'msie 6.0')); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 36c10c3ca6..0d7a0a288c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -88,15 +88,11 @@ $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); $container->setAlias('cache.driver.install', 'cache.driver'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); -$phpbb_class_loader_ext->register(); $phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader->register(); +$phpbb_class_loader_ext = $container->get('class_loader.ext'); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); -$phpbb_class_loader->set_cache($container->get('cache.driver')); $phpbb_dispatcher = $container->get('dispatcher'); $request = $container->get('request'); From 35c78c127b8fefe56512faaf83c47bee28908e0f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 1 Apr 2012 00:59:23 +0200 Subject: [PATCH 021/666] [feature/dic] Make table_config a DIC parameter PHPBB3-10739 --- phpBB/config/parameters.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml index da29ae8417..3bedc9a135 100644 --- a/phpBB/config/parameters.yml +++ b/phpBB/config/parameters.yml @@ -1,4 +1,5 @@ parameters: + core.table_prefix: phpbb_ cache.driver.class: phpbb_cache_driver_file dbal.driver.class: dbal_mysqli dbal.dbhost: @@ -7,5 +8,5 @@ parameters: dbal.dbname: phpbb_dev dbal.dbport: dbal.new_link: false - tables.config: phpbb_config - tables.ext: phpbb_ext + tables.config: %core.table_prefix%config + tables.ext: %core.table_prefix%ext From e78fbfef9c6aac1349d18454a4292781d661795c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 1 Apr 2012 01:13:00 +0200 Subject: [PATCH 022/666] [feature/dic] Move cron.lock_db into DIC PHPBB3-10739 --- phpBB/config/services.yml | 7 +++++++ phpBB/cron.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 6f2ed8c7c3..6817d8f015 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -114,3 +114,10 @@ services: arguments: - @cron.task_provider - @cache.driver + + cron.lock_db: + class: phpbb_lock_db + arguments: + - cron_lock + - @config + - @dbal.conn diff --git a/phpBB/cron.php b/phpBB/cron.php index 36b771f1b7..df48c2dc4d 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -71,7 +71,7 @@ else output_image(); } -$cron_lock = new phpbb_lock_db('cron_lock', $config, $db); +$cron_lock = $container->get('cron.lock_db'); if ($cron_lock->acquire()) { if ($config['use_system_cron']) From 328d4f1820c372e6ae9ee6af60afb5e53a2f015e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Thu, 5 Apr 2012 18:41:27 -0500 Subject: [PATCH 023/666] [ticket/10661] Added   to enumerated recipients (prosilver) Added missing   to enumerated recipients after IF statements to see if it is a group or not (to_recipient.IS_GROUP and bcc_recipient.ISGROUP), in posting_editor template in prosilver style. PHPBB3-10661 --- phpBB/styles/prosilver/template/posting_editor.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 5f7fb8408e..fc98a95a17 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -17,7 +17,7 @@
- {to_recipient.NAME} {to_recipient.NAME_FULL}  + {to_recipient.NAME}{to_recipient.NAME_FULL}   
@@ -29,7 +29,7 @@
- {bcc_recipient.NAME}{bcc_recipient.NAME_FULL}  + {bcc_recipient.NAME}{bcc_recipient.NAME_FULL}   
@@ -50,7 +50,7 @@
- {to_recipient.NAME}{to_recipient.NAME_FULL}  + {to_recipient.NAME}{to_recipient.NAME_FULL}   
From 2e76620c8824da62f97cfdaee8f9b1014159fd7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 00:22:55 +0200 Subject: [PATCH 024/666] [feature/dic] Rewrite cron system to use DIC PHPBB3-10739 --- phpBB/common.php | 37 +++++----- phpBB/config/cron_tasks.yml | 72 +++++++++++++++++++ phpBB/config/services.yml | 5 +- phpBB/download/file.php | 27 +++---- phpBB/includes/cron/manager.php | 36 ++-------- .../cron/task/core/prune_all_forums.php | 25 ++++--- phpBB/includes/cron/task/core/prune_forum.php | 44 +++++------- phpBB/includes/cron/task/core/queue.php | 18 +++-- phpBB/includes/cron/task/core/tidy_cache.php | 17 +++-- .../includes/cron/task/core/tidy_database.php | 15 ++-- phpBB/includes/cron/task/core/tidy_search.php | 24 ++++--- .../includes/cron/task/core/tidy_sessions.php | 14 ++-- .../includes/cron/task/core/tidy_warnings.php | 18 +++-- phpBB/includes/cron/task/provider.php | 45 ++++++------ phpBB/install/index.php | 21 +++--- phpBB/viewforum.php | 4 +- 16 files changed, 257 insertions(+), 165 deletions(-) create mode 100644 phpBB/config/cron_tasks.yml diff --git a/phpBB/common.php b/phpBB/common.php index 51478662d7..c9eb5d217b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -88,42 +88,43 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -$container = new ContainerBuilder(); -$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); $loader->load('parameters.yml'); $loader->load('services.yml'); -$container->setParameter('core.root_path', $phpbb_root_path); -$container->setParameter('core.php_ext', $phpEx); +$phpbb_container->setParameter('core.root_path', $phpbb_root_path); +$phpbb_container->setParameter('core.php_ext', $phpEx); +$phpbb_container->set('container', $phpbb_container); // Setup class loader first -$phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); // set up caching -$cache = $container->get('cache'); +$cache = $phpbb_container->get('cache'); // Instantiate some basic classes -$phpbb_dispatcher = $container->get('dispatcher'); -$request = $container->get('request'); -$user = $container->get('user'); -$auth = $container->get('auth'); -$db = $container->get('dbal.conn'); +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function // Grab global variables, re-cache if necessary -$config = $container->get('config'); +$config = $phpbb_container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions -$phpbb_extension_manager = $container->get('ext.manager'); -$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); +$phpbb_extension_manager = $phpbb_container->get('ext.manager'); +$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); -$template = $container->get('template'); -$style = $container->get('style'); +$template = $phpbb_container->get('template'); +$style = $phpbb_container->get('style'); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); @@ -136,5 +137,5 @@ foreach ($cache->obtain_hooks() as $hook) if (!$config['use_system_cron']) { - $cron = $container->get('cron.manager'); + $cron = $phpbb_container->get('cron.manager'); } diff --git a/phpBB/config/cron_tasks.yml b/phpBB/config/cron_tasks.yml new file mode 100644 index 0000000000..18a198fa27 --- /dev/null +++ b/phpBB/config/cron_tasks.yml @@ -0,0 +1,72 @@ +services: + cron.task.core.prune_all_forums: + class: phpbb_cron_task_core_prune_all_forums + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @dbal.conn + tags: + - { name: cron.task } + + cron.task.core.prune_forum: + class: phpbb_cron_task_core_prune_forum + arguments: + - %core.root_path% + - %core.php_ext% + - @config + - @dbal.conn + tags: + - { name: cron.task } + + cron.task.core.queue: + class: phpbb_cron_task_core_queue + arguments: + - %core.root_path% + - %core.php_ext% + - @config + tags: + - { name: cron.task } + + cron.task.core.tidy_cache: + class: phpbb_cron_task_core_tidy_cache + arguments: + - @config + - @cache.driver + tags: + - { name: cron.task } + + cron.task.core.tidy_database: + class: phpbb_cron_task_core_tidy_database + arguments: + - %core.root_path% + - %core.php_ext% + - @config + tags: + - { name: cron.task } + + cron.task.core.tidy_search: + class: phpbb_cron_task_core_tidy_search + arguments: + - %core.root_path% + - %core.php_ext% + - @config + tags: + - { name: cron.task } + + cron.task.core.tidy_sessions: + class: phpbb_cron_task_core_tidy_sessions + arguments: + - @config + - @user + tags: + - { name: cron.task } + + cron.task.core.tidy_warnings: + class: phpbb_cron_task_core_tidy_warnings + arguments: + - %core.root_path% + - %core.php_ext% + - @config + tags: + - { name: cron.task } diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 6817d8f015..f6e92112f7 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,3 +1,6 @@ +imports: + - { resource: cron_tasks.yml } + services: class_loader: class: phpbb_class_loader @@ -107,7 +110,7 @@ services: cron.task_provider: class: phpbb_cron_task_provider arguments: - - @ext.manager + - @container cron.manager: class: phpbb_cron_manager diff --git a/phpBB/download/file.php b/phpBB/download/file.php index eabb6edbbb..7213e3ac3f 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -44,23 +44,24 @@ if (isset($_GET['avatar'])) require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - $container = new ContainerBuilder(); - $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); + $phpbb_container = new ContainerBuilder(); + $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); $loader->load('parameters.yml'); $loader->load('services.yml'); - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $phpEx); + $phpbb_container->setParameter('core.root_path', $phpbb_root_path); + $phpbb_container->setParameter('core.php_ext', $phpEx); + $phpbb_container->set('container', $phpbb_container); - $phpbb_class_loader = $container->get('class_loader'); - $phpbb_class_loader_ext = $container->get('class_loader.ext'); + $phpbb_class_loader = $phpbb_container->get('class_loader'); + $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); // set up caching - $cache = $container->get('cache'); + $cache = $phpbb_container->get('cache'); - $phpbb_dispatcher = $container->get('dispatcher'); - $request = $container->get('request'); - $db = $container->get('dbal.conn'); + $phpbb_dispatcher = $phpbb_container->get('dispatcher'); + $request = $phpbb_container->get('request'); + $db = $phpbb_container->get('dbal.conn'); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) @@ -71,13 +72,13 @@ if (isset($_GET['avatar'])) request_var('', 0, false, false, $request); - $config = $container->get('config'); + $config = $phpbb_container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions - $phpbb_extension_manager = $container->get('ext.manager'); - $phpbb_subscriber_loader = $container->get('event.subscriber_loader'); + $phpbb_extension_manager = $phpbb_container->get('ext.manager'); + $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); // worst-case default $browser = strtolower($request->header('User-Agent', 'msie 6.0')); diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 7a78a1b054..5abbc987dd 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -35,26 +35,25 @@ class phpbb_cron_manager /** * Constructor. Loads all available tasks. * - * @param array|Traversable $task_names Provides an iterable set of task names + * @param array|Traversable $tasks Provides an iterable set of task names */ - public function __construct($task_names) + public function __construct($tasks) { - $this->load_tasks($task_names); + $this->load_tasks($tasks); } /** * Loads tasks given by name, wraps them * and puts them into $this->tasks. * - * @param array|Traversable $task_names Array of strings + * @param array|Traversable $tasks Array of instances of phpbb_cron_task * * @return void */ - public function load_tasks($task_names) + public function load_tasks($tasks) { - foreach ($task_names as $task_name) + foreach ($tasks as $task) { - $task = new $task_name(); $wrapper = new phpbb_cron_task_wrapper($task); $this->tasks[] = $wrapper; } @@ -120,27 +119,4 @@ class phpbb_cron_manager } return null; } - - /** - * Creates an instance of parametrized cron task $name with args $args. - * The constructed task is wrapped with cron task wrapper before being returned. - * - * @param string $name The task name, which is the same as cron task class name. - * @param array $args Will be passed to the task class's constructor. - * - * @return phpbb_cron_task_wrapper|null - */ - public function instantiate_task($name, array $args) - { - $task = $this->find_task($name); - if ($task) - { - // task here is actually an instance of cron task wrapper - $class = $task->get_name(); - $task = new $class($args); - // need to wrap the new task too - $task = new phpbb_cron_task_wrapper($task); - } - return $task; - } } diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 15b93a9ca6..f3a179d81b 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -26,6 +26,16 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base { + private $phpbb_root_path, $phpEx, $config, $db; + + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, dbal $db) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + $this->db = $db; + } + /** * Runs this cron task. * @@ -33,19 +43,17 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base */ public function run() { - global $phpbb_root_path, $phpEx, $db; - if (!function_exists('auto_prune')) { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_admin.' . $this->phpEx); } $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq FROM ' . FORUMS_TABLE . " - WHERE enable_prune = 1 + WHERE enable_prune = 1 AND prune_next < " . time(); - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) { if ($row['prune_days']) { @@ -57,7 +65,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']); } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); } /** @@ -69,7 +77,6 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base */ public function is_runnable() { - global $config; - return (bool) $config['use_system_cron']; + return (bool) $this->config['use_system_cron']; } } diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 7686fd4281..1f717904ef 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -26,31 +26,25 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_cron_task_parametrized { + private $phpbb_root_path, $phpEx, $config, $db; private $forum_data; + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, dbal $db) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + $this->db = $db; + } + /** - * Constructor. - * - * If $forum_data is given, it is assumed to contain necessary information - * about a single forum that is to be pruned. - * - * If $forum_data is not given, forum id will be retrieved via request_var - * and a database query will be performed to load the necessary information - * about the forum. + * Manually set forum data. * * @param array $forum_data Information about a forum to be pruned. */ - public function __construct($forum_data = null) + public function set_forum_data($forum_data) { - global $db; - if ($forum_data) - { - $this->forum_data = $forum_data; - } - else - { - $this->forum_data = null; - } + $this->forum_data = $forum_data; } /** @@ -60,10 +54,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p */ public function run() { - global $phpbb_root_path, $phpEx; if (!function_exists('auto_prune')) { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_admin.' . $this->phpEx); } if ($this->forum_data['prune_days']) @@ -90,8 +83,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p */ public function is_runnable() { - global $config; - return !$config['use_system_cron'] && $this->forum_data; + return !$this->config['use_system_cron'] && $this->forum_data; } /** @@ -130,8 +122,6 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p */ public function parse_parameters(phpbb_request_interface $request) { - global $db; - $this->forum_data = null; if ($request->is_set('f')) { @@ -140,9 +130,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if ($row) { diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index 1c72eec7c7..70db94f31d 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -22,6 +22,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_queue extends phpbb_cron_task_base { + private $phpbb_root_path, $phpEx, $config; + + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + } + /** * Runs this cron task. * @@ -29,10 +38,9 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base */ public function run() { - global $phpbb_root_path, $phpEx; if (!class_exists('queue')) { - include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx); } $queue = new queue(); $queue->process(); @@ -47,8 +55,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base */ public function is_runnable() { - global $phpbb_root_path, $phpEx; - return file_exists($phpbb_root_path . 'cache/queue.' . $phpEx); + return file_exists($this->phpbb_root_path . 'cache/queue.' . $this->phpEx); } /** @@ -61,7 +68,6 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['last_queue_run'] < time() - $config['queue_interval_config']; + return $this->config['last_queue_run'] < time() - $this->config['queue_interval_config']; } } diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index c9dc0bd9ae..530f25dacb 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -22,6 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base { + private $config, $cache; + + public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache) + { + $this->config = $config; + $this->cache = $cache; + } + /** * Runs this cron task. * @@ -29,8 +37,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base */ public function run() { - global $cache; - $cache->tidy(); + $this->cache->tidy(); } /** @@ -43,8 +50,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base */ public function is_runnable() { - global $cache; - return method_exists($cache, 'tidy'); + return method_exists($this->cache, 'tidy'); } /** @@ -58,7 +64,6 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['cache_last_gc'] < time() - $config['cache_gc']; + return $this->config['cache_last_gc'] < time() - $this->config['cache_gc']; } } diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index 80a1901b1e..910e27cf20 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -22,6 +22,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base { + private $phpbb_root_path, $phpEx, $config; + + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + } + /** * Runs this cron task. * @@ -29,10 +38,9 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base */ public function run() { - global $phpbb_root_path, $phpEx; if (!function_exists('tidy_database')) { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_admin.' . $this->phpEx); } tidy_database(); } @@ -48,7 +56,6 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['database_last_gc'] < time() - $config['database_gc']; + return $this->config['database_last_gc'] < time() - $this->config['database_gc']; } } diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index 8a0b1b690a..1b8a0b8151 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -24,6 +24,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base { + private $phpbb_root_path, $phpEx, $config; + + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + } + /** * Runs this cron task. * @@ -31,14 +40,12 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base */ public function run() { - global $phpbb_root_path, $phpEx, $config, $error; - // Select the search method - $search_type = basename($config['search_type']); + $search_type = basename($this->config['search_type']); if (!class_exists($search_type)) { - include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + include($this->phpbb_root_path . "includes/search/$search_type." . $this->phpEx); } // We do some additional checks in the module to ensure it can actually be utilised @@ -62,12 +69,10 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base */ public function is_runnable() { - global $phpbb_root_path, $phpEx, $config; - // Select the search method - $search_type = basename($config['search_type']); + $search_type = basename($this->config['search_type']); - return file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx); + return file_exists($this->phpbb_root_path . 'includes/search/' . $search_type . '.' . $this->phpEx); } /** @@ -81,7 +86,6 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['search_last_gc'] < time() - $config['search_gc']; + return $this->config['search_last_gc'] < time() - $this->config['search_gc']; } } diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index ae7bb242b8..b409c93868 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -22,6 +22,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base { + private $config, $user; + + public function __construct(phpbb_config $config, phpbb_user $user) + { + $this->config = $config; + $this->user = $user; + } + /** * Runs this cron task. * @@ -29,8 +37,7 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base */ public function run() { - global $user; - $user->session_gc(); + $this->user->session_gc(); } /** @@ -44,7 +51,6 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['session_last_gc'] < time() - $config['session_gc']; + return $this->config['session_last_gc'] < time() - $this->config['session_gc']; } } diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index e1434e7087..3b87a300d0 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -24,6 +24,15 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base { + private $phpbb_root_path, $phpEx, $config; + + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + } + /** * Runs this cron task. * @@ -31,10 +40,9 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base */ public function run() { - global $phpbb_root_path, $phpEx; if (!function_exists('tidy_warnings')) { - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_admin.' . $this->phpEx); } tidy_warnings(); } @@ -48,8 +56,7 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base */ public function is_runnable() { - global $config; - return (bool) $config['warnings_expire_days']; + return (bool) $this->config['warnings_expire_days']; } /** @@ -63,7 +70,6 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base */ public function should_run() { - global $config; - return $config['warnings_last_gc'] < time() - $config['warnings_gc']; + return $this->config['warnings_last_gc'] < time() - $this->config['warnings_gc']; } } diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index 1482051699..acc3d455ec 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -15,6 +15,8 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\DependencyInjection\Container; + /** * Provides cron manager with tasks * @@ -22,27 +24,30 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_cron_task_provider extends phpbb_extension_provider +class phpbb_cron_task_provider implements IteratorAggregate { - /** - * Finds cron task names using the extension manager. - * - * All PHP files in includes/cron/task/core/ are considered tasks. Tasks - * in extensions have to be located in a directory called cron or a subdir - * of a directory called cron. The class and filename must end in a _task - * suffix. Additionally all PHP files in includes/cron/task/core/ are - * tasks. - * - * @return array List of task names - */ - protected function find() - { - $finder = $this->extension_manager->get_finder(); + private $container; - return $finder - ->extension_suffix('_task') - ->extension_directory('/cron') - ->core_path('includes/cron/task/core/') - ->get_classes(); + public function __construct(Container $container) + { + $this->container = $container; + } + + /** + * Retrieve an iterator over all items + * + * @return ArrayIterator An iterator for the array of cron tasks + */ + public function getIterator() + { + $definitions = $this->container->findTaggedServiceIds('cron.task'); + + $tasks = array(); + foreach ($definitions as $name => $definition) + { + $tasks[] = $this->container->get($name); + } + + return new ArrayIterator($tasks); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 0d7a0a288c..dd84e2d519 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -79,23 +79,24 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); -$container = new ContainerBuilder(); -$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); $loader->load('parameters.yml'); $loader->load('services.yml'); -$container->setParameter('core.root_path', $phpbb_root_path); -$container->setParameter('core.php_ext', $phpEx); -$container->setAlias('cache.driver.install', 'cache.driver'); +$phpbb_container->setParameter('core.root_path', $phpbb_root_path); +$phpbb_container->setParameter('core.php_ext', $phpEx); +$phpbb_container->setAlias('cache.driver.install', 'cache.driver'); +$phpbb_container->set('container', $phpbb_container); -$phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); // set up caching -$cache = $container->get('cache'); +$cache = $phpbb_container->get('cache'); -$phpbb_dispatcher = $container->get('dispatcher'); -$request = $container->get('request'); +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 2d91581cf4..16342ba1b3 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -193,7 +193,9 @@ if ($forum_data['forum_topics_per_page']) // Do the forum Prune thang - cron type job ... if (!$config['use_system_cron']) { - $task = $cron->instantiate_task('cron_task_core_prune_forum', $forum_data); + $task = $container->get('cron.task.core.prune_forum'); + $task = new phpbb_cron_task_wrapper($task); + $task->set_forum_data($forum_data); if ($task && $task->is_ready()) { $url = $task->get_url(); From aa0c995ed9cdafa2dfaca23b54d5b4cf6323f794 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 13:15:27 +0200 Subject: [PATCH 025/666] [feature/dic] Protect config directory via .htaccess PHPBB3-10739 --- phpBB/config/.htaccess | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 phpBB/config/.htaccess diff --git a/phpBB/config/.htaccess b/phpBB/config/.htaccess new file mode 100644 index 0000000000..aa5afc1640 --- /dev/null +++ b/phpBB/config/.htaccess @@ -0,0 +1,4 @@ + + Order Allow,Deny + Deny from All + \ No newline at end of file From 3896ee953fbdb45d0485c0b5dcdfca47409a22ed Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 14:34:35 +0200 Subject: [PATCH 026/666] [feature/dic] Give all cron tasks a name, change some manager usage PHPBB3-10739 --- phpBB/config/services.yml | 3 ++- phpBB/cron.php | 2 +- phpBB/includes/cron/manager.php | 15 ++++++++++++--- phpBB/includes/cron/task/base.php | 22 ++++++++++++++++++++++ phpBB/includes/cron/task/provider.php | 7 ++++++- phpBB/includes/cron/task/task.php | 7 +++++++ phpBB/includes/cron/task/wrapper.php | 20 ++++++-------------- phpBB/viewforum.php | 8 +++++--- 8 files changed, 61 insertions(+), 23 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index f6e92112f7..94d641ab8b 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -116,7 +116,8 @@ services: class: phpbb_cron_manager arguments: - @cron.task_provider - - @cache.driver + - %core.root_path% + - %core.php_ext% cron.lock_db: class: phpbb_lock_db diff --git a/phpBB/cron.php b/phpBB/cron.php index df48c2dc4d..be328db4de 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -61,7 +61,7 @@ function do_cron($cron_lock, $run_tasks) if ($config['use_system_cron']) { - $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); + $cron = $container->get('cron.manager'); } else { diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 5abbc987dd..5ea909eb2c 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -32,13 +32,18 @@ class phpbb_cron_manager */ protected $tasks = array(); + protected $phpbb_root_path, $phpEx; + /** * Constructor. Loads all available tasks. * * @param array|Traversable $tasks Provides an iterable set of task names */ - public function __construct($tasks) + public function __construct($tasks, $phpbb_root_path, $phpEx) { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->load_tasks($tasks); } @@ -54,8 +59,7 @@ class phpbb_cron_manager { foreach ($tasks as $task) { - $wrapper = new phpbb_cron_task_wrapper($task); - $this->tasks[] = $wrapper; + $this->tasks[] = $this->wrap_task($task); } } @@ -119,4 +123,9 @@ class phpbb_cron_manager } return null; } + + public function wrap_task(phpbb_cron_task $task) + { + return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->phpEx); + } } diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php index c05fb9a87c..94a2f267b4 100644 --- a/phpBB/includes/cron/task/base.php +++ b/phpBB/includes/cron/task/base.php @@ -28,6 +28,28 @@ if (!defined('IN_PHPBB')) */ abstract class phpbb_cron_task_base implements phpbb_cron_task { + private $name; + + /** + * Returns the name of the task. + * + * @return string Name of wrapped task. + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the name of the task. + * + * @param string $name The task name + */ + public function set_name($name) + { + $this->name = $name; + } + /** * Returns whether this cron task can run, given current board configuration. * diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index acc3d455ec..9994d707f2 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -45,7 +45,12 @@ class phpbb_cron_task_provider implements IteratorAggregate $tasks = array(); foreach ($definitions as $name => $definition) { - $tasks[] = $this->container->get($name); + $task = $this->container->get($name); + if ($task instanceof phpbb_cron_task_base) { + $task->set_name($name); + } + + $tasks[] = $task; } return new ArrayIterator($tasks); diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php index 2f2a9e51f9..7b08fed413 100644 --- a/phpBB/includes/cron/task/task.php +++ b/phpBB/includes/cron/task/task.php @@ -21,6 +21,13 @@ if (!defined('IN_PHPBB')) */ interface phpbb_cron_task { + /** + * Returns the name of the task. + * + * @return string Name of wrapped task. + */ + public function get_name(); + /** * Runs this cron task. * diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index 66c45189e5..75b7fbdaa3 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -23,6 +23,8 @@ if (!defined('IN_PHPBB')) */ class phpbb_cron_task_wrapper { + private $task, $phpbb_root_path, $phpEx; + /** * Constructor. * @@ -30,9 +32,11 @@ class phpbb_cron_task_wrapper * * @param phpbb_cron_task $task The cron task to wrap. */ - public function __construct(phpbb_cron_task $task) + public function __construct(phpbb_cron_task $task, $phpbb_root_path, $phpEx) { $this->task = $task; + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; } /** @@ -61,16 +65,6 @@ class phpbb_cron_task_wrapper return $this->task->is_runnable() && $this->task->should_run(); } - /** - * Returns the name of wrapped task. It is the same as the wrapped class's class name. - * - * @return string Class name of wrapped task. - */ - public function get_name() - { - return get_class($this->task); - } - /** * Returns a url through which this task may be invoked via web. * @@ -82,8 +76,6 @@ class phpbb_cron_task_wrapper */ public function get_url() { - global $phpbb_root_path, $phpEx; - $name = $this->get_name(); if ($this->is_parametrized()) { @@ -98,7 +90,7 @@ class phpbb_cron_task_wrapper { $extra = ''; } - $url = append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $name . $extra); + $url = append_sid($this->phpbb_root_path . 'cron.' . $this->phpEx, 'cron_type=' . $name . $extra); return $url; } diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 16342ba1b3..25c8f5aa6d 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -193,10 +193,12 @@ if ($forum_data['forum_topics_per_page']) // Do the forum Prune thang - cron type job ... if (!$config['use_system_cron']) { - $task = $container->get('cron.task.core.prune_forum'); - $task = new phpbb_cron_task_wrapper($task); + $cron = $container->get('cron.manager'); + + $task = $cron->find_task('cron.task.core.prune_forum'); $task->set_forum_data($forum_data); - if ($task && $task->is_ready()) + + if ($task->is_ready()) { $url = $task->get_url(); $template->assign_var('RUN_CRON_TASK', 'cron'); From 0a5348a1376fafb487884086a70069bea8c5640b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 14:37:04 +0200 Subject: [PATCH 027/666] [feature/dic] Rename occurances of $container to $phpbb_container PHPBB3-10739 --- phpBB/cron.php | 4 ++-- phpBB/viewforum.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/cron.php b/phpBB/cron.php index be328db4de..95d2f8f9b6 100644 --- a/phpBB/cron.php +++ b/phpBB/cron.php @@ -61,7 +61,7 @@ function do_cron($cron_lock, $run_tasks) if ($config['use_system_cron']) { - $cron = $container->get('cron.manager'); + $cron = $phpbb_container->get('cron.manager'); } else { @@ -71,7 +71,7 @@ else output_image(); } -$cron_lock = $container->get('cron.lock_db'); +$cron_lock = $phpbb_container->get('cron.lock_db'); if ($cron_lock->acquire()) { if ($config['use_system_cron']) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 25c8f5aa6d..76d5c8ccff 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -193,7 +193,7 @@ if ($forum_data['forum_topics_per_page']) // Do the forum Prune thang - cron type job ... if (!$config['use_system_cron']) { - $cron = $container->get('cron.manager'); + $cron = $phpbb_container->get('cron.manager'); $task = $cron->find_task('cron.task.core.prune_forum'); $task->set_forum_data($forum_data); From 3ebe89cb7eff57c3ffdbe0b7dcd9cdc35b48d26b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 15:05:28 +0200 Subject: [PATCH 028/666] [feature/dic] Fix test suite for dic-powered cron PHPBB3-10739 --- phpBB/includes/cron/task/provider.php | 4 +- tests/cron/ext/testext/cron/dummy_task.php | 5 +++ .../includes/cron/task/core/dummy_task.php | 5 +++ .../cron/task/core/second_dummy_task.php | 5 +++ tests/cron/manager_test.php | 32 +++++++-------- tests/cron/task_provider_test.php | 41 ++++++++++++------- tests/cron/tasks/simple_not_runnable.php | 5 +++ tests/cron/tasks/simple_ready.php | 5 +++ tests/cron/tasks/simple_should_not_run.php | 5 +++ 9 files changed, 74 insertions(+), 33 deletions(-) diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index 9994d707f2..6adac77eb8 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -15,7 +15,7 @@ if (!defined('IN_PHPBB')) exit; } -use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\TaggedContainerInterface; /** * Provides cron manager with tasks @@ -28,7 +28,7 @@ class phpbb_cron_task_provider implements IteratorAggregate { private $container; - public function __construct(Container $container) + public function __construct(TaggedContainerInterface $container) { $this->container = $container; } diff --git a/tests/cron/ext/testext/cron/dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php index 996f5b39cf..a31806c1b1 100644 --- a/tests/cron/ext/testext/cron/dummy_task.php +++ b/tests/cron/ext/testext/cron/dummy_task.php @@ -11,6 +11,11 @@ class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/includes/cron/task/core/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php index 6e2e2db636..ce3e91a9ba 100644 --- a/tests/cron/includes/cron/task/core/dummy_task.php +++ b/tests/cron/includes/cron/task/core/dummy_task.php @@ -11,6 +11,11 @@ class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/includes/cron/task/core/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php index 8cd0bddfc0..76a55588f9 100644 --- a/tests/cron/includes/cron/task/core/second_dummy_task.php +++ b/tests/cron/includes/cron/task/core/second_dummy_task.php @@ -11,6 +11,11 @@ class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base { public static $was_run = 0; + public function get_name() + { + return get_class($this); + } + public function run() { self::$was_run++; diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index f433fc9a9b..8ed33b06e2 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -19,10 +19,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase { public function setUp() { - $this->manager = new phpbb_cron_manager(array( - 'phpbb_cron_task_core_dummy_task', - 'phpbb_cron_task_core_second_dummy_task', - 'phpbb_ext_testext_cron_dummy_task', + $this->manager = $this->create_cron_manager(array( + new phpbb_cron_task_core_dummy_task(), + new phpbb_cron_task_core_second_dummy_task(), + new phpbb_ext_testext_cron_dummy_task(), )); $this->task_name = 'phpbb_cron_task_core_dummy_task'; } @@ -34,13 +34,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase $this->assertEquals($this->task_name, $task->get_name()); } - public function test_manager_instantiates_task_by_name() - { - $task = $this->manager->instantiate_task($this->task_name, array()); - $this->assertInstanceOf('phpbb_cron_task_wrapper', $task); - $this->assertEquals($this->task_name, $task->get_name()); - } - public function test_manager_finds_all_ready_tasks() { $tasks = $this->manager->find_all_ready_tasks(); @@ -55,10 +48,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_only_ready_tasks() { - $manager = new phpbb_cron_manager(array( - 'phpbb_cron_task_core_simple_ready', - 'phpbb_cron_task_core_simple_not_runnable', - 'phpbb_cron_task_core_simple_should_not_run', + $manager = $this->create_cron_manager(array( + new phpbb_cron_task_core_simple_ready(), + new phpbb_cron_task_core_simple_not_runnable(), + new phpbb_cron_task_core_simple_should_not_run(), )); $tasks = $manager->find_all_ready_tasks(); $task_names = $this->tasks_to_names($tasks); @@ -70,8 +63,15 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase $names = array(); foreach ($tasks as $task) { - $names[] = get_class($task->task); + $names[] = $task->get_name(); } return $names; } + + private function create_cron_manager($tasks) + { + global $phpbb_root_path, $phpEx; + + return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx); + } } diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php index 4547c61a55..4458d811a5 100644 --- a/tests/cron/task_provider_test.php +++ b/tests/cron/task_provider_test.php @@ -7,37 +7,48 @@ * */ -require_once dirname(__FILE__) . '/../mock/extension_manager.php'; +require_once dirname(__FILE__) . '/includes/cron/task/core/dummy_task.php'; +require_once dirname(__FILE__) . '/includes/cron/task/core/second_dummy_task.php'; +require_once dirname(__FILE__) . '/ext/testext/cron/dummy_task.php'; class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase { public function setUp() { - $this->extension_manager = new phpbb_mock_extension_manager( - dirname(__FILE__) . '/', - array( - 'testext' => array( - 'ext_name' => 'testext', - 'ext_active' => true, - 'ext_path' => 'ext/testext/' - ), - )); - $this->provider = new phpbb_cron_task_provider($this->extension_manager); + $this->tasks = array( + 'phpbb_cron_task_core_dummy_task', + 'phpbb_cron_task_core_second_dummy_task', + 'phpbb_ext_testext_cron_dummy_task', + ); + + $container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface'); + $container + ->expects($this->once()) + ->method('findTaggedServiceIds') + ->will($this->returnValue(array_flip($this->tasks))); + $container + ->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function ($name) { + return new $name; + })); + + $this->provider = new phpbb_cron_task_provider($container); } public function test_manager_finds_shipped_tasks() { - $tasks = array(); + $task_names = array(); foreach ($this->provider as $task) { - $tasks[] = $task; + $task_names[] = $task->get_name(); } - sort($tasks); + sort($task_names); $this->assertEquals(array( 'phpbb_cron_task_core_dummy_task', 'phpbb_cron_task_core_second_dummy_task', 'phpbb_ext_testext_cron_dummy_task', - ), $tasks); + ), $task_names); } } diff --git a/tests/cron/tasks/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php index 837f28f1c0..56d484eacd 100644 --- a/tests/cron/tasks/simple_not_runnable.php +++ b/tests/cron/tasks/simple_not_runnable.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php index de5f10e491..8aa0507406 100644 --- a/tests/cron/tasks/simple_ready.php +++ b/tests/cron/tasks/simple_ready.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } diff --git a/tests/cron/tasks/simple_should_not_run.php b/tests/cron/tasks/simple_should_not_run.php index c2a41616f6..58f6df2616 100644 --- a/tests/cron/tasks/simple_should_not_run.php +++ b/tests/cron/tasks/simple_should_not_run.php @@ -2,6 +2,11 @@ class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base { + public function get_name() + { + return get_class($this); + } + public function run() { } From e6a1d37634fb9f9f53125460abdaf9c90d8858a7 Mon Sep 17 00:00:00 2001 From: Senky Date: Mon, 9 Apr 2012 16:23:42 +0200 Subject: [PATCH 029/666] [ticket/9918] $redirect variable used from now According to comment marc1706 added to tracker http://tracker.phpbb.com/browse/PHPBB3-9918?focusedCommentId=35120&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-35120 I changed files to fit his second advice - redirect is kept in hidden_fields and other code changed. PHPBB3-9918 --- phpBB/includes/mcp/mcp_forum.php | 4 ++-- phpBB/includes/mcp/mcp_topic.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index fec1edc872..889e0a368c 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -433,7 +433,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -442,7 +442,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '

' . $return_link); } } diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index d4ba89b04c..7ed4908280 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -529,7 +529,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -538,7 +538,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '

' . $return_link); } } @@ -635,7 +635,7 @@ function merge_posts($topic_id, $to_topic_id) confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); } - $redirect = request_var('redirect', "index.$phpEx"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -644,7 +644,7 @@ function merge_posts($topic_id, $to_topic_id) } else { - meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id")); + meta_refresh(3, $redirect); trigger_error($user->lang[$success_msg] . '

' . $return_link); } } From 807eccc97632ea8beee4485ef926e4436da2554c Mon Sep 17 00:00:00 2001 From: Senky Date: Sun, 15 Apr 2012 19:13:08 +0200 Subject: [PATCH 030/666] [ticket/9918] default values in request_var changed to one string As per marc1706's note, all request_var functions now have only one string in default value PHPBB3-9918 --- phpBB/includes/mcp/mcp_forum.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 889e0a368c..4e40af934c 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -433,7 +433,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields); } - $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 7ed4908280..e96c025795 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -529,7 +529,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) confirm_box(false, ($action == 'split_all') ? 'SPLIT_TOPIC_ALL' : 'SPLIT_TOPIC_BEYOND', $s_hidden_fields); } - $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) @@ -635,7 +635,7 @@ function merge_posts($topic_id, $to_topic_id) confirm_box(false, 'MERGE_POSTS', $s_hidden_fields); } - $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&t=$to_topic_id"); + $redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id"); $redirect = reapply_sid($redirect); if (!$success_msg) From 953e829b527acd6de80fee93bb1bfd08c6010c51 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 25 Mar 2012 20:57:35 -0400 Subject: [PATCH 031/666] [feature/prune-users] Non-cosmetic changes per bantu's review. PHPBB3-9622 --- phpBB/includes/acp/acp_prune.php | 1 + phpBB/includes/functions_user.php | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 145c0c3854..101eb5a1ed 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -343,6 +343,7 @@ class acp_prune { $s_group_list .= '
+
{L_REQUIREMENTS} @@ -61,34 +60,35 @@
+
{L_AUTHOR_INFORMATION} -
-
-
{md_authors.AUTHOR_NAME}
-
- -
-
-
{md_authors.AUTHOR_EMAIL}
-
- - -
-
-
{md_authors.AUTHOR_HOMEPAGE}
-
- - -
-
-
{md_authors.AUTHOR_ROLE}
-
- - -

+
+
+
+
{md_authors.AUTHOR_NAME}
+
+ +
+
+
{md_authors.AUTHOR_EMAIL}
+
+ + +
+
+
{md_authors.AUTHOR_HOMEPAGE}
+
+ + +
+
+
{md_authors.AUTHOR_ROLE}
+
+ +
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 0e1d5c88a8..0e825514e6 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -155,11 +155,11 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - private function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) { foreach ($phpbb_extension_manager->all_enabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); $template->assign_block_vars('enabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), @@ -178,11 +178,11 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - private function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) { foreach ($phpbb_extension_manager->all_disabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); $template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), @@ -201,13 +201,13 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - function list_available_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_available_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) { $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured()); foreach ($uninstalled as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); $template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 9dfc0a067c..9342c936f9 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -131,7 +131,7 @@ class phpbb_extension_manager * @param string $template The template manager * @return phpbb_extension_metadata_manager Instance of the metadata manager */ - public function get_extension_metadata($name, phpbb_template $template) + public function get_extension_metadata_manager($name, phpbb_template $template) { return new phpbb_extension_metadata_manager($name, $this->db, $this, $this->phpbb_root_path, $this->php_ext, $template, $this->config); } diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index d2dc72e5fc..aa163b1190 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -28,62 +28,9 @@ class phpbb_extension_metadata_manager protected $phpbb_root_path; protected $template; protected $ext_name; - public $metadata; + protected $metadata; protected $metadata_file; - /** - * Array of validation regular expressions, see __call() - * - * @var mixed - */ - protected $validation = array( - 'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#', - 'type' => '#^phpbb3-extension$#', - 'description' => '#.*#', - 'version' => '#.+#', - 'licence' => '#.+#', - //'homepage' => '#([\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(\b|\W(? array( - 'display-name' => '#.*#', - ), - ); - - /** - * Magic method to catch validation calls - * - * @param string $name - * @param mixed $arguments - * @return int - */ - public function __call($name, $arguments) - { - // Validation Magic methods - if (strpos($name, 'validate_') === 0) - { - // Remove validate_ - $name = substr($name, 9); - - // Replace underscores with dashes (underscores are not used) - $name = str_replace('_', '-', $name); - - if (strpos($name, 'extra-') === 0) - { - // Remove extra_ - $name = substr($name, 6); - - if (isset($this->validation['extra'][$name])) - { - // Extra means it's optional, so return true if it does not exist - return (isset($this->metadata['extra'][$name])) ? preg_match($this->validation['extra'][$name], $this->metadata['extra'][$name]) : true; - } - } - else if (isset($this->validation[$name]) && isset($this->metadata[$name])) - { - return preg_match($this->validation[$name], $this->metadata[$name]); - } - } - } - /** * Creates the metadata manager * @@ -136,7 +83,7 @@ class phpbb_extension_metadata_manager case 'all': default: // Validate the metadata - if (!$this->validate_metadata_array()) + if (!$this->validate()) { return false; } @@ -145,17 +92,17 @@ class phpbb_extension_metadata_manager break; case 'name': - return ($this->validate_name()) ? $this->metadata['name'] : false; + return ($this->validate('name')) ? $this->metadata['name'] : false; break; case 'display-name': - if (isset($this->metadata['extra']['display-name']) && $this->validate_extra_display_name()) + if (isset($this->metadata['extra']['display-name'])) { return $this->metadata['extra']['display-name']; } else { - return ($this->validate_name()) ? $this->metadata['name'] : false; + return ($this->validate('name')) ? $this->metadata['name'] : false; } break; // TODO: Add remaining cases as needed @@ -216,7 +163,7 @@ class phpbb_extension_metadata_manager /** * This array handles the validation and cleaning of the array * - * @return array Contains the cleaned and validated metadata array + * @return array Contains the cleaned metadata array */ private function clean_metadata_array() { @@ -227,40 +174,44 @@ class phpbb_extension_metadata_manager } /** - * This array handles the validation of strings - * - * @return bool True if validation succeeded, False if failed - */ - public function validate_metadata_array() - { - foreach ($this->validation as $name => $regex) - { - if (is_array($regex)) + * Validate fields + * + * @param string $name ("all" for display and enable validation + * "display" for name, type, and authors + * "name", "type") + * @return Bool False if validation fails, true if valid + */ + public function validate($name = 'display') + { + // Basic fields + $fields = array( + 'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#', + 'type' => '#^phpbb3-extension$#', + 'licence' => '#.+#', + 'version' => '#.+#', + ); + + if (isset($fields[$name])) + { + return (isset($this->metadata[$name])) ? (bool) preg_match($this->validation[$name], $this->metadata[$name]) : false; + } + + // Validate all fields + if ($name == 'all') + { + foreach ($fields as $field => $data) { - foreach ($regex as $extra_name => $extra_regex) - { - $type = 'validate_' . $name . '_' . $extra_name; - - if (!$this->$type()) - { - return false; - } - } - } - else - { - - $type = 'validate_' . $name; - - if (!$this->$type()) + if (!$this->validate($field)) { return false; } } + + return $this->validate_authors(); } - return $this->validate_authors(); - } + return true; + } /** * Validates the contents of the authors field @@ -292,19 +243,10 @@ class phpbb_extension_metadata_manager */ public function validate_enable() { - $validate = array( - 'require_phpbb', - 'require_php', - ); - - foreach ($validate as $type) + // Check for phpBB, PHP versions + if (!$this->validate_require_phpbb || !$this->validate_require_php) { - $type = 'validate_' . $type; - - if (!$this->$type()) - { - return false; - } + return false; } return true; @@ -372,10 +314,10 @@ class phpbb_extension_metadata_manager $this->template->assign_vars(array( 'MD_NAME' => htmlspecialchars($this->metadata['name']), 'MD_TYPE' => htmlspecialchars($this->metadata['type']), - 'MD_DESCRIPTION' => htmlspecialchars($this->metadata['description']), + 'MD_DESCRIPTION' => (isset($this->metadata['description'])) ? htmlspecialchars($this->metadata['description']) : '', 'MD_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '', - 'MD_VERSION' => htmlspecialchars($this->metadata['version']), - 'MD_TIME' => htmlspecialchars($this->metadata['time']), + 'MD_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '', + 'MD_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '', 'MD_LICENCE' => htmlspecialchars($this->metadata['licence']), 'MD_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', 'MD_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '', @@ -386,7 +328,7 @@ class phpbb_extension_metadata_manager { $this->template->assign_block_vars('md_authors', array( 'AUTHOR_NAME' => htmlspecialchars($author['name']), - 'AUTHOR_EMAIL' => $author['email'], + 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '', 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '', 'AUTHOR_ROLE' => (isset($author['role'])) ? htmlspecialchars($author['role']) : '', )); From 89f4cf6a8c10f9b0875cf7f278016aff67eb38fc Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 19:46:21 -0500 Subject: [PATCH 510/666] [ticket/10631] Use exceptions for errors. Build action list dynamically. PHPBB3-10631 --- phpBB/adm/style/acp_ext_list.html | 21 +++- phpBB/includes/acp/acp_extensions.php | 111 +++++++++++++----- phpBB/includes/exception/metadata.php | 69 +++++++++++ phpBB/includes/extension/metadata_manager.php | 72 ++++++------ phpBB/language/en/acp/extensions.php | 2 +- 5 files changed, 205 insertions(+), 70 deletions(-) create mode 100644 phpBB/includes/exception/metadata.php diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index b3b1b84949..65051cbae0 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -26,11 +26,16 @@ {enabled.EXT_NAME} {L_DETAILS} - {L_DISABLE}  - | {L_PURGE} + + + {enabled.actions.L_ACTION} +  |  + + + {L_DISABLED} {L_EXTENSIONS} @@ -38,9 +43,15 @@ {disabled.EXT_NAME} - {L_DETAILS} - {L_ENABLE}  - {L_PURGE}  + + {L_DETAILS} + + + + {disabled.actions.L_ACTION} +  |  + + diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 0e825514e6..a833c8c482 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -22,11 +22,21 @@ class acp_extensions { var $u_action; + private $db; + private $config; + private $template; + private $user; + function main() { // Start the page global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx; + $this->db = $db; + $this->config = $config; + $this->template = $template; + $this->user = $user; + $user->add_lang(array('install', 'acp/extensions')); $this->page_title = 'ACP_EXTENSIONS'; @@ -39,9 +49,10 @@ class acp_extensions { $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, ".$phpEx", $template, $config); - if ($md_manager->get_metadata('all') === false) - { - trigger_error('EXTENSION_INVALID'); + try{ + $md_manager->get_metadata('all'); + } catch( Exception $e ) { + trigger_error($e); } } @@ -50,9 +61,9 @@ class acp_extensions { case 'list': default: - $this->list_enabled_exts($phpbb_extension_manager, $template); - $this->list_disabled_exts($phpbb_extension_manager, $template); - $this->list_available_exts($phpbb_extension_manager, $template); + $this->list_enabled_exts($phpbb_extension_manager); + $this->list_disabled_exts($phpbb_extension_manager); + $this->list_available_exts($phpbb_extension_manager); $this->tpl_name = 'acp_ext_list'; break; @@ -155,19 +166,28 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - public function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager) { foreach ($phpbb_extension_manager->all_enabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - $template->assign_block_vars('enabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + try { + $this->template->assign_block_vars('enabled', array( + 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, - 'U_PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, - 'U_DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . $name, - )); + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + )); + + $this->output_actions('enabled', array( + 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . $name, + 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, + )); + } catch( Exception $e ) { + $this->template->assign_block_vars('disabled', array( + 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + )); + } } } @@ -178,19 +198,28 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - public function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager) { foreach ($phpbb_extension_manager->all_disabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - $template->assign_block_vars('disabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + try { + $this->template->assign_block_vars('disabled', array( + 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, - 'U_PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, - 'U_ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, - )); + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + )); + + $this->output_actions('disabled', array( + 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, + 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, + )); + } catch( Exception $e ) { + $this->template->assign_block_vars('disabled', array( + 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + )); + } } } @@ -201,19 +230,45 @@ class acp_extensions * @param $template An instance of the template engine * @return null */ - public function list_available_exts(phpbb_extension_manager $phpbb_extension_manager, phpbb_template $template) + public function list_available_exts(phpbb_extension_manager $phpbb_extension_manager) { $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured()); foreach ($uninstalled as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $template); + $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - $template->assign_block_vars('disabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + try { + $this->template->assign_block_vars('disabled', array( + 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, - 'U_ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + )); + + $this->output_actions('disabled', array( + 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, + )); + } catch( Exception $e ) { + $this->template->assign_block_vars('disabled', array( + 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + )); + } + } + } + + /** + * Output actions to a block + * + * @param string $block + * @param array $actions + */ + private function output_actions($block, $actions) + { + foreach ($actions as $lang => $url) + { + $this->template->assign_block_vars($block . '.actions', array( + 'L_ACTION' => $this->user->lang($lang), + 'U_ACTION' => $url, )); } } diff --git a/phpBB/includes/exception/metadata.php b/phpBB/includes/exception/metadata.php new file mode 100644 index 0000000000..93cc337f55 --- /dev/null +++ b/phpBB/includes/exception/metadata.php @@ -0,0 +1,69 @@ +code = $code; + $this->field_name = $field_name; + } + + public function __toString() + { + return sprintf($this->getErrorMessage(), $this->field_name); + } + + public function getErrorMessage() + { + switch ($this->code) + { + case self::NOT_SET: + return 'The "%s" meta field has not been set.'; + break; + + case self::INVALID: + return 'The "%s" meta field is not valid.'; + break; + + case self::FILE_GET_CONTENTS: + return 'file_get_contents failed on %s'; + break; + + case self::JSON_DECODE: + return 'json_decode failed on %s'; + break; + + case self::FILE_DOES_NOT_EXIST: + return 'Required file does not exist at %s'; + break; + + default: + return 'An unexpected error has occurred.'; + break; + } + } +} \ No newline at end of file diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index aa163b1190..126331ce1c 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -56,27 +56,18 @@ class phpbb_extension_metadata_manager * Processes and gets the metadata requested * * @param string $element All for all metadata that it has and is valid, otherwise specify which section you want by its shorthand term. - * @return bool|array Contains all of the requested metadata or bool False if not valid + * @return array Contains all of the requested metadata, throws an exception on failure */ public function get_metadata($element = 'all') { // TODO: Check ext_name exists and is an extension that exists - if (!$this->set_metadata_file()) - { - return false; - } + $this->set_metadata_file(); // Fetch the metadata - if (!$this->fetch_metadata()) - { - return false; - } + $this->fetch_metadata(); // Clean the metadata - if (!$this->clean_metadata_array()) - { - return false; - } + $this->clean_metadata_array(); switch ($element) { @@ -112,46 +103,42 @@ class phpbb_extension_metadata_manager /** * Sets the filepath of the metadata file * - * @return boolean Set to true if it exists + * @return boolean Set to true if it exists, throws an exception on failure */ private function set_metadata_file() { $ext_filepath = $this->extension_manager->get_extension_path($this->ext_name); - $metadata_filepath = $this->phpbb_root_path . $ext_filepath . '/composer.json'; + $metadata_filepath = $this->phpbb_root_path . $ext_filepath . 'composer.json'; $this->metadata_file = $metadata_filepath; if (!file_exists($this->metadata_file)) { - return false; - } - else - { - return true; + throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_DOES_NOT_EXIST, $this->metadata_file); } } /** * Gets the contents of the composer.json file * - * @return bool True of false (if loading succeeded or failed) + * @return bool True if success, throws an exception on failure */ private function fetch_metadata() { if (!file_exists($this->metadata_file)) { - return false; + throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_DOES_NOT_EXIST, $this->metadata_file); } else { if (!($file_contents = file_get_contents($this->metadata_file))) { - return false; + throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_GET_CONTENTS, $this->metadata_file); } if (($metadata = json_decode($file_contents, true)) === NULL) { - return false; + throw new phpbb_exception_metadata(phpbb_exception_metadata::JSON_DECODE, $this->metadata_file); } $this->metadata = $metadata; @@ -161,7 +148,7 @@ class phpbb_extension_metadata_manager } /** - * This array handles the validation and cleaning of the array + * This array handles the cleaning of the array * * @return array Contains the cleaned metadata array */ @@ -179,7 +166,7 @@ class phpbb_extension_metadata_manager * @param string $name ("all" for display and enable validation * "display" for name, type, and authors * "name", "type") - * @return Bool False if validation fails, true if valid + * @return Bool True if valid, throws an exception if invalid */ public function validate($name = 'display') { @@ -193,21 +180,34 @@ class phpbb_extension_metadata_manager if (isset($fields[$name])) { - return (isset($this->metadata[$name])) ? (bool) preg_match($this->validation[$name], $this->metadata[$name]) : false; + if (!isset($this->metadata[$name])) + { + throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, $name); + } + + if (!preg_match($fields[$name], $this->metadata[$name])) + { + throw new phpbb_exception_metadata(phpbb_exception_metadata::INVALID, $name); + } } // Validate all fields if ($name == 'all') + { + $this->validate('display'); + + $this->validate_enable(); + } + + // Validate display fields + if ($name == 'display') { foreach ($fields as $field => $data) { - if (!$this->validate($field)) - { - return false; - } + $this->validate($field); } - return $this->validate_authors(); + $this->validate_authors(); } return true; @@ -216,20 +216,20 @@ class phpbb_extension_metadata_manager /** * Validates the contents of the authors field * - * @return boolean True when passes validation + * @return boolean True when passes validation, throws exception if invalid */ private function validate_authors() { if (empty($this->metadata['authors'])) { - return false; + throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, 'authors'); } foreach ($this->metadata['authors'] as $author) { if (!isset($author['name'])) { - return false; + throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, 'author name'); } } @@ -244,7 +244,7 @@ class phpbb_extension_metadata_manager public function validate_enable() { // Check for phpBB, PHP versions - if (!$this->validate_require_phpbb || !$this->validate_require_php) + if (!$this->validate_require_phpbb() || !$this->validate_require_php()) { return false; } diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index 903ec249a8..0adaff10c8 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -39,7 +39,7 @@ $lang = array_merge($lang, array( 'EXTENSIONS' => 'Extensions', 'EXTENSIONS_ADMIN' => 'Extensions Manager', 'EXTENSIONS_EXPLAIN' => 'The Extensions Manager is a tool in your phpBB Board which allows you to manage all of your extensions statuses and view information about them.', - 'EXTENSION_INVALID' => 'The selected extension is not valid.', + 'EXTENSION_INVALID_LIST' => 'The "%s" extension is not valid.

%s

', 'EXTENSION_NOT_AVAILABLE' => 'The selected extension is not available for this board, please verify your phpBB and PHP versions are allowed (see the details page).', 'DETAILS' => 'Details', From 2a7e1292919ed1397a3f1951e510d84565d002d7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 20:28:04 -0500 Subject: [PATCH 511/666] [ticket/10631] Simplify exceptions PHPBB-10631 --- phpBB/includes/acp/acp_extensions.php | 28 +++++--- phpBB/includes/exception/metadata.php | 69 ------------------- phpBB/includes/extension/exception.php | 27 ++++++++ phpBB/includes/extension/metadata_manager.php | 16 ++--- 4 files changed, 55 insertions(+), 85 deletions(-) delete mode 100644 phpBB/includes/exception/metadata.php create mode 100644 phpBB/includes/extension/exception.php diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index a833c8c482..287074395d 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -49,9 +49,12 @@ class acp_extensions { $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, ".$phpEx", $template, $config); - try{ + try + { $md_manager->get_metadata('all'); - } catch( Exception $e ) { + } + catch(phpbb_extension_exception $e) + { trigger_error($e); } } @@ -172,7 +175,8 @@ class acp_extensions { $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - try { + try + { $this->template->assign_block_vars('enabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), @@ -183,7 +187,9 @@ class acp_extensions 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . $name, 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, )); - } catch( Exception $e ) { + } + catch(phpbb_extension_exception $e) + { $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); @@ -204,7 +210,8 @@ class acp_extensions { $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - try { + try + { $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), @@ -215,7 +222,9 @@ class acp_extensions 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, )); - } catch( Exception $e ) { + } + catch(phpbb_extension_exception $e) + { $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); @@ -238,7 +247,8 @@ class acp_extensions { $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); - try { + try + { $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), @@ -248,7 +258,9 @@ class acp_extensions $this->output_actions('disabled', array( 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, )); - } catch( Exception $e ) { + } + catch(phpbb_extension_exception $e) + { $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); diff --git a/phpBB/includes/exception/metadata.php b/phpBB/includes/exception/metadata.php deleted file mode 100644 index 93cc337f55..0000000000 --- a/phpBB/includes/exception/metadata.php +++ /dev/null @@ -1,69 +0,0 @@ -code = $code; - $this->field_name = $field_name; - } - - public function __toString() - { - return sprintf($this->getErrorMessage(), $this->field_name); - } - - public function getErrorMessage() - { - switch ($this->code) - { - case self::NOT_SET: - return 'The "%s" meta field has not been set.'; - break; - - case self::INVALID: - return 'The "%s" meta field is not valid.'; - break; - - case self::FILE_GET_CONTENTS: - return 'file_get_contents failed on %s'; - break; - - case self::JSON_DECODE: - return 'json_decode failed on %s'; - break; - - case self::FILE_DOES_NOT_EXIST: - return 'Required file does not exist at %s'; - break; - - default: - return 'An unexpected error has occurred.'; - break; - } - } -} \ No newline at end of file diff --git a/phpBB/includes/extension/exception.php b/phpBB/includes/extension/exception.php new file mode 100644 index 0000000000..e08a8912ea --- /dev/null +++ b/phpBB/includes/extension/exception.php @@ -0,0 +1,27 @@ +getMessage(); + } +} \ No newline at end of file diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 126331ce1c..27b04d4c08 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -114,7 +114,7 @@ class phpbb_extension_metadata_manager if (!file_exists($this->metadata_file)) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_DOES_NOT_EXIST, $this->metadata_file); + throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file); } } @@ -127,18 +127,18 @@ class phpbb_extension_metadata_manager { if (!file_exists($this->metadata_file)) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_DOES_NOT_EXIST, $this->metadata_file); + throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file); } else { if (!($file_contents = file_get_contents($this->metadata_file))) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::FILE_GET_CONTENTS, $this->metadata_file); + throw new phpbb_extension_exception('file_get_contents failed on ' . $this->metadata_file); } if (($metadata = json_decode($file_contents, true)) === NULL) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::JSON_DECODE, $this->metadata_file); + throw new phpbb_extension_exception('json_decode failed on ' . $this->metadata_file); } $this->metadata = $metadata; @@ -182,12 +182,12 @@ class phpbb_extension_metadata_manager { if (!isset($this->metadata[$name])) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, $name); + throw new phpbb_extension_exception("Required meta field '$name' has not been set."); } if (!preg_match($fields[$name], $this->metadata[$name])) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::INVALID, $name); + throw new phpbb_extension_exception("Meta field '$name' is invalid."); } } @@ -222,14 +222,14 @@ class phpbb_extension_metadata_manager { if (empty($this->metadata['authors'])) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, 'authors'); + throw new phpbb_extension_exception("Required meta field 'authors' has not been set."); } foreach ($this->metadata['authors'] as $author) { if (!isset($author['name'])) { - throw new phpbb_exception_metadata(phpbb_exception_metadata::NOT_SET, 'author name'); + throw new phpbb_extension_exception("Required meta field 'author name' has not been set."); } } From fd5ed30052a03d812cfdf95f4e86b0c997b5aa10 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 20:34:47 -0500 Subject: [PATCH 512/666] [ticket/10631] Update tests PHPBB3-10631 --- tests/extension/manager_test.php | 2 ++ tests/test_framework/phpbb_functional_test_case.php | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 45bed247ae..df7f9f3029 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -27,6 +27,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $this->extension_manager = new phpbb_extension_manager( $this->new_dbal(), + new phpbb_config(array()) 'phpbb_ext', dirname(__FILE__) . '/', '.php', @@ -90,6 +91,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case { $extension_manager = new phpbb_extension_manager( $this->new_dbal(), + new phpbb_config(array()), 'phpbb_ext', dirname(__FILE__) . '/', '.php' diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b953017d0a..a1deeb2b63 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -125,6 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->extension_manager = new phpbb_extension_manager( $this->get_db(), + new phpbb_config(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", From 747c16240fd56be0e24b4c54f01c82aa0a78b91e Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 20:40:54 -0500 Subject: [PATCH 513/666] [ticket/10631] get_extension_metadata_manager -> create_extension_metadata_manager PHPBB3-10631 --- phpBB/includes/acp/acp_extensions.php | 6 +++--- phpBB/includes/extension/manager.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 287074395d..4f59ea309b 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -173,7 +173,7 @@ class acp_extensions { foreach ($phpbb_extension_manager->all_enabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); + $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template); try { @@ -208,7 +208,7 @@ class acp_extensions { foreach ($phpbb_extension_manager->all_disabled() as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); + $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template); try { @@ -245,7 +245,7 @@ class acp_extensions foreach ($uninstalled as $name => $location) { - $md_manager = $phpbb_extension_manager->get_extension_metadata_manager($name, $this->template); + $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template); try { diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 9342c936f9..9a518c215f 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -131,7 +131,7 @@ class phpbb_extension_manager * @param string $template The template manager * @return phpbb_extension_metadata_manager Instance of the metadata manager */ - public function get_extension_metadata_manager($name, phpbb_template $template) + public function create_extension_metadata_manager($name, phpbb_template $template) { return new phpbb_extension_metadata_manager($name, $this->db, $this, $this->phpbb_root_path, $this->php_ext, $template, $this->config); } From 1de061c4defd405da279cb1f398d7d2e4e75c573 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 24 Jul 2012 20:48:38 -0500 Subject: [PATCH 514/666] [ticket/10631] Fixing an error in the test script PHPBB3-10631 --- tests/extension/manager_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index df7f9f3029..5cde5bccdb 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -27,7 +27,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $this->extension_manager = new phpbb_extension_manager( $this->new_dbal(), - new phpbb_config(array()) + new phpbb_config(array()), 'phpbb_ext', dirname(__FILE__) . '/', '.php', From c39f11750fa73007edd936bf600ea53ac8f95f3a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 24 Jul 2012 21:08:11 -0500 Subject: [PATCH 515/666] [ticket/10631] A _start_ on a metadata manager test. No idea if it runs without errors, I do not have the testing stuff setup. PHPBB3-10631 --- .../phpbb_extension_metadata_manager_test.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/extension/phpbb_extension_metadata_manager_test.php diff --git a/tests/extension/phpbb_extension_metadata_manager_test.php b/tests/extension/phpbb_extension_metadata_manager_test.php new file mode 100644 index 0000000000..7a7f7a785d --- /dev/null +++ b/tests/extension/phpbb_extension_metadata_manager_test.php @@ -0,0 +1,55 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->extension_manager = new phpbb_extension_manager( + $this->new_dbal(), + new phpbb_config(array()), + 'phpbb_ext', + dirname(__FILE__) . '/', + '.php', + new phpbb_mock_cache + ); + } + + public function test_bar() + { + $phpbb_extension_metadata_manager = new phpbb_extension_metadata_manager( + 'bar', + $this->new_dbal(), + new phpbb_config(array()), + $this->extension_manager, + dirname(__FILE__) . '/', + '.php', + new phpbb_template( + dirname(__FILE__) . '/', + '.php', + new phpbb_config(array()), + new phpbb_user(), + new phpbb_style_resource_locator() + ), + new phpbb_mock_cache + ); + + //$this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); + } +} \ No newline at end of file From 8c5786636a534baf28b4820a730f85948c3dccf4 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 25 Jul 2012 22:14:38 -0500 Subject: [PATCH 516/666] [ticket/10631] Fix class construct arguments in test PHPBB3-10631 --- tests/extension/phpbb_extension_metadata_manager_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/extension/phpbb_extension_metadata_manager_test.php b/tests/extension/phpbb_extension_metadata_manager_test.php index 7a7f7a785d..0d115d37eb 100644 --- a/tests/extension/phpbb_extension_metadata_manager_test.php +++ b/tests/extension/phpbb_extension_metadata_manager_test.php @@ -36,7 +36,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $phpbb_extension_metadata_manager = new phpbb_extension_metadata_manager( 'bar', $this->new_dbal(), - new phpbb_config(array()), $this->extension_manager, dirname(__FILE__) . '/', '.php', @@ -47,7 +46,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case new phpbb_user(), new phpbb_style_resource_locator() ), - new phpbb_mock_cache + new phpbb_config(array()) ); //$this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); From 500879520c40a71f0b83799ab3e59c86c12a801a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 28 Jul 2012 14:59:55 -0500 Subject: [PATCH 517/666] [ticket/10631] Metadata manager tests PHPBB3-10631 --- phpBB/includes/extension/metadata_manager.php | 55 +-- tests/extension/ext/foo/composer.json | 22 ++ tests/extension/metadata_manager_test.php | 374 ++++++++++++++++++ .../phpbb_extension_metadata_manager_test.php | 54 --- 4 files changed, 424 insertions(+), 81 deletions(-) create mode 100644 tests/extension/ext/foo/composer.json create mode 100644 tests/extension/metadata_manager_test.php delete mode 100644 tests/extension/phpbb_extension_metadata_manager_test.php diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 27b04d4c08..c7f52b7c02 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -178,36 +178,37 @@ class phpbb_extension_metadata_manager 'version' => '#.+#', ); - if (isset($fields[$name])) + switch ($name) { - if (!isset($this->metadata[$name])) - { - throw new phpbb_extension_exception("Required meta field '$name' has not been set."); - } + case 'all': + $this->validate('display'); - if (!preg_match($fields[$name], $this->metadata[$name])) - { - throw new phpbb_extension_exception("Meta field '$name' is invalid."); - } - } + $this->validate_enable(); + break; - // Validate all fields - if ($name == 'all') - { - $this->validate('display'); + case 'display': + foreach ($fields as $field => $data) + { + $this->validate($field); + } - $this->validate_enable(); - } + $this->validate_authors(); + break; - // Validate display fields - if ($name == 'display') - { - foreach ($fields as $field => $data) - { - $this->validate($field); - } + default: + if (isset($fields[$name])) + { + if (!isset($this->metadata[$name])) + { + throw new phpbb_extension_exception("Required meta field '$name' has not been set."); + } - $this->validate_authors(); + if (!preg_match($fields[$name], $this->metadata[$name])) + { + throw new phpbb_extension_exception("Meta field '$name' is invalid."); + } + } + break; } return true; @@ -218,7 +219,7 @@ class phpbb_extension_metadata_manager * * @return boolean True when passes validation, throws exception if invalid */ - private function validate_authors() + public function validate_authors() { if (empty($this->metadata['authors'])) { @@ -258,7 +259,7 @@ class phpbb_extension_metadata_manager * * @return boolean True when passes validation */ - private function validate_require_phpbb() + public function validate_require_phpbb() { if (!isset($this->metadata['require']['phpbb'])) { @@ -273,7 +274,7 @@ class phpbb_extension_metadata_manager * * @return boolean True when passes validation */ - private function validate_require_php() + public function validate_require_php() { if (!isset($this->metadata['require']['php'])) { diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/foo/composer.json new file mode 100644 index 0000000000..14af677dac --- /dev/null +++ b/tests/extension/ext/foo/composer.json @@ -0,0 +1,22 @@ +{ + "name": "foo/example", + "type": "phpbb3-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", + "licence": "GNU GPL v2", + "authors": [{ + "name": "Nathan Guse", + "username": "EXreaction", + "email": "nathaniel.guse@gmail.com", + "homepage": "http://lithiumstudios.org", + "role": "N/A" + }], + "require": { + "php": ">=5.3", + "phpbb": "3.1.0-dev" + }, + "extra": { + "display-name": "phpBB Foo Extension" + } +} diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php new file mode 100644 index 0000000000..67630e9f36 --- /dev/null +++ b/tests/extension/metadata_manager_test.php @@ -0,0 +1,374 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->phpbb_root_path = dirname(__FILE__) . '/'; + + $this->extension_manager = new phpbb_extension_manager( + $this->new_dbal(), + new phpbb_config(array()), + 'phpbb_ext', + $this->phpbb_root_path, + '.php', + new phpbb_mock_cache + ); + } + + // Should fail from missing composer.json + public function test_bar() + { + $ext_name = 'bar'; + + $manager = new phpbb_extension_metadata_manager_test( + $ext_name, + $this->new_dbal(), + $this->extension_manager, + $this->phpbb_root_path, + '.php', + new phpbb_template( + $this->phpbb_root_path, + '.php', + new phpbb_config(array()), + new phpbb_user(), + new phpbb_style_resource_locator() + ), + new phpbb_config(array()) + ); + + try + { + $manager->get_metadata(); + } + catch(phpbb_extension_exception $e){} + + $this->assertEquals((string) $e, 'The required file does not exist: ' . $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'); + } + + // Should be the same as a direct json_decode of the composer.json file + public function test_foo() + { + $ext_name = 'foo'; + + $manager = new phpbb_extension_metadata_manager_test( + $ext_name, + $this->new_dbal(), + $this->extension_manager, + $this->phpbb_root_path, + '.php', + new phpbb_template( + $this->phpbb_root_path, + '.php', + new phpbb_config(array()), + new phpbb_user(), + new phpbb_style_resource_locator() + ), + new phpbb_config(array()) + ); + + try + { + $metadata = $manager->get_metadata(); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + $json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/foo/composer.json'), true); + + $this->assertEquals($metadata, $json); + } + + public function test_validator() + { + $ext_name = 'validator'; + + $manager = new phpbb_extension_metadata_manager_test( + $ext_name, + $this->new_dbal(), + $this->extension_manager, + $this->phpbb_root_path, + '.php', + new phpbb_template( + $this->phpbb_root_path, + '.php', + new phpbb_config(array()), + new phpbb_user(), + new phpbb_style_resource_locator() + ), + new phpbb_config(array( + 'version' => '3.1.0', + )) + ); + + // Non-existant data + try + { + $manager->validate('name'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.'); + + try + { + $manager->validate('type'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.'); + + try + { + $manager->validate('licence'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.'); + + try + { + $manager->validate('version'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.'); + + try + { + $manager->validate_authors(); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.'); + + $manager->merge_metadata(array( + 'authors' => array( + array(), + ), + )); + + try + { + $manager->validate_authors(); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.'); + + + // Invalid data + $manager->set_metadata(array( + 'name' => 'asdf', + 'type' => 'asdf', + 'licence' => '', + 'version' => '', + )); + + try + { + $manager->validate('name'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Meta field \'name\' is invalid.'); + + try + { + $manager->validate('type'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Meta field \'type\' is invalid.'); + + try + { + $manager->validate('licence'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.'); + + try + { + $manager->validate('version'); + } + catch(phpbb_extension_exception $e) {} + $this->assertEquals((string) $e, 'Meta field \'version\' is invalid.'); + + + // Valid data + $manager->set_metadata(array( + 'name' => 'test/foo', + 'type' => 'phpbb3-extension', + 'licence' => 'GPL v2', + 'version' => '1.0.0', + )); + + try + { + $this->assertEquals(true, $manager->validate('enable')); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Too high of requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => '10.0.0', + 'phpbb' => '3.2.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(false, $manager->validate_require_php()); + $this->assertEquals(false, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Too high of requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => '5.3.0', + 'phpbb' => '3.1.0-beta', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(true, $manager->validate_require_php()); + $this->assertEquals(true, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Too high of requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => '>' . phpversion(), + 'phpbb' => '>3.1.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(false, $manager->validate_require_php()); + $this->assertEquals(false, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Too high of current install + $manager->merge_metadata(array( + 'require' => array( + 'php' => '<' . phpversion(), + 'phpbb' => '<3.1.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(false, $manager->validate_require_php()); + $this->assertEquals(false, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Matching requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => phpversion(), + 'phpbb' => '3.1.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(true, $manager->validate_require_php()); + $this->assertEquals(true, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Matching requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => '>=' . phpversion(), + 'phpbb' => '>=3.1.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(true, $manager->validate_require_php()); + $this->assertEquals(true, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + + + // Matching requirements + $manager->merge_metadata(array( + 'require' => array( + 'php' => '<=' . phpversion(), + 'phpbb' => '<=3.1.0', // config is set to 3.1.0 + ), + )); + + try + { + $this->assertEquals(true, $manager->validate_require_php()); + $this->assertEquals(true, $manager->validate_require_phpbb()); + } + catch(phpbb_extension_exception $e) + { + $this->fail($e); + } + } +} + +class phpbb_extension_metadata_manager_test extends phpbb_extension_metadata_manager +{ + public function set_metadata($metadata) + { + $this->metadata = $metadata; + } + + public function merge_metadata($metadata) + { + $this->metadata = array_merge($this->metadata, $metadata); + } +} \ No newline at end of file diff --git a/tests/extension/phpbb_extension_metadata_manager_test.php b/tests/extension/phpbb_extension_metadata_manager_test.php deleted file mode 100644 index 0d115d37eb..0000000000 --- a/tests/extension/phpbb_extension_metadata_manager_test.php +++ /dev/null @@ -1,54 +0,0 @@ -createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml'); - } - - protected function setUp() - { - parent::setUp(); - - $this->extension_manager = new phpbb_extension_manager( - $this->new_dbal(), - new phpbb_config(array()), - 'phpbb_ext', - dirname(__FILE__) . '/', - '.php', - new phpbb_mock_cache - ); - } - - public function test_bar() - { - $phpbb_extension_metadata_manager = new phpbb_extension_metadata_manager( - 'bar', - $this->new_dbal(), - $this->extension_manager, - dirname(__FILE__) . '/', - '.php', - new phpbb_template( - dirname(__FILE__) . '/', - '.php', - new phpbb_config(array()), - new phpbb_user(), - new phpbb_style_resource_locator() - ), - new phpbb_config(array()) - ); - - //$this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); - } -} \ No newline at end of file From 36465c9a205c356b0662e45b4fded79c4b476547 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 29 Jul 2012 20:08:30 -0500 Subject: [PATCH 518/666] [ticket/10631] Functional acp_extensions test, cleanup PHPBB3-10631 --- phpBB/adm/style/acp_ext_list.html | 4 +- phpBB/includes/acp/acp_extensions.php | 38 +-- tests/extension/acp.php | 226 ++++++++++++++++++ tests/extension/ext/foo/composer.json | 2 +- tests/extension/ext/vendor/moo/composer.json | 22 ++ tests/extension/metadata_manager_test.php | 99 ++++---- .../phpbb_functional_test_case.php | 54 +++++ .../phpbb_test_case_helpers.php | 108 +++++++++ 8 files changed, 481 insertions(+), 72 deletions(-) create mode 100644 tests/extension/acp.php create mode 100644 tests/extension/ext/vendor/moo/composer.json diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index 65051cbae0..b654a80caa 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -23,7 +23,7 @@ - + {enabled.EXT_NAME} {L_DETAILS} @@ -41,7 +41,7 @@ {L_DISABLED} {L_EXTENSIONS} - + {disabled.EXT_NAME} {L_DETAILS} diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 4f59ea309b..c4d9f0c0e0 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -72,7 +72,7 @@ class acp_extensions break; case 'enable_pre': - if (!$md_manager->validate_enable()) + if (!$md_manager->validate_enable() || $phpbb_extension_manager->enabled($ext_name)) { trigger_error('EXTENSION_NOT_AVAILABLE'); } @@ -81,7 +81,7 @@ class acp_extensions $template->assign_vars(array( 'PRE' => true, - 'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . $ext_name, + 'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name), )); break; @@ -95,7 +95,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . $ext_name); + meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); } $this->tpl_name = 'acp_ext_enable'; @@ -106,11 +106,16 @@ class acp_extensions break; case 'disable_pre': + if (!$phpbb_extension_manager->enabled($ext_name)) + { + trigger_error('EXTENSION_NOT_AVAILABLE'); + } + $this->tpl_name = 'acp_ext_disable'; $template->assign_vars(array( 'PRE' => true, - 'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . $ext_name, + 'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name), )); break; @@ -119,7 +124,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . $ext_name); + meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name)); } $this->tpl_name = 'acp_ext_disable'; @@ -134,7 +139,7 @@ class acp_extensions $template->assign_vars(array( 'PRE' => true, - 'U_PURGE' => $this->u_action . '&action=purge&ext_name=' . $ext_name, + 'U_PURGE' => $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name), )); break; @@ -143,7 +148,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . $ext_name); + meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); } $this->tpl_name = 'acp_ext_purge'; @@ -166,7 +171,6 @@ class acp_extensions * Lists all the enabled extensions and dumps to the template * * @param $phpbb_extension_manager An instance of the extension manager - * @param $template An instance of the template engine * @return null */ public function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager) @@ -180,12 +184,12 @@ class acp_extensions $this->template->assign_block_vars('enabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); $this->output_actions('enabled', array( - 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . $name, - 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, + 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . urlencode($name), + 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . urlencode($name), )); } catch(phpbb_extension_exception $e) @@ -201,7 +205,6 @@ class acp_extensions * Lists all the disabled extensions and dumps to the template * * @param $phpbb_extension_manager An instance of the extension manager - * @param $template An instance of the template engine * @return null */ public function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager) @@ -215,12 +218,12 @@ class acp_extensions $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, - 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . $name, + 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), + 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . urlencode($name), )); } catch(phpbb_extension_exception $e) @@ -236,7 +239,6 @@ class acp_extensions * Lists all the available extensions and dumps to the template * * @param $phpbb_extension_manager An instance of the extension manager - * @param $template An instance of the template engine * @return null */ public function list_available_exts(phpbb_extension_manager $phpbb_extension_manager) @@ -252,11 +254,11 @@ class acp_extensions $this->template->assign_block_vars('disabled', array( 'EXT_NAME' => $md_manager->get_metadata('display-name'), - 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . $name, + 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); $this->output_actions('disabled', array( - 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . $name, + 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), )); } catch(phpbb_extension_exception $e) diff --git a/tests/extension/acp.php b/tests/extension/acp.php new file mode 100644 index 0000000000..c078a3f7b4 --- /dev/null +++ b/tests/extension/acp.php @@ -0,0 +1,226 @@ +copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); + + // Then empty the ext/ directory on the board (for accurate test cases) + self::$helper->empty_dir($phpbb_root_path . 'ext/'); + + // Copy our ext/ files from the test case to the board + self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/ext/', $phpbb_root_path . 'ext/')); + } + + public function setUp() + { + parent::setUp(); + + $this->get_db(); + + // Clear the phpbb_ext table + $this->db->sql_query('DELETE FROM phpbb_ext'); + + // Insert our base data + $insert_rows = array( + array( + 'ext_name' => 'foo', + 'ext_active' => true, + 'ext_state' => 'b:0;', + ), + array( + 'ext_name' => 'vendor/moo', + 'ext_active' => false, + 'ext_state' => 'b:0;', + ), + + // do not exist + array( + 'ext_name' => 'test2', + 'ext_active' => true, + 'ext_state' => 'b:0;', + ), + array( + 'ext_name' => 'test3', + 'ext_active' => false, + 'ext_state' => 'b:0;', + ), + ); + $this->db->sql_multi_insert('phpbb_ext', $insert_rows); + + $this->login(); + $this->admin_login(); + + $this->add_lang('acp/extensions'); + } + + /** + * This should only be called once after the tests are run. + * This is used to remove the files copied to the phpBB install + */ + static public function tearDownAfterClass() + { + global $phpbb_root_path; + + // Copy back the board installed extensions from the temp directory + self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); + + self::$copied_files[] = $phpbb_root_path . 'store/temp_ext/'; + + // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) + self::$helper->remove_files(self::$copied_files); + } + + public function test_list() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); + + $this->assertCount(1, $crawler->filter('.ext_enabled')); + $this->assertCount(4, $crawler->filter('.ext_disabled')); + + $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text()); + + $this->assertContains('The "test2" extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); + + $this->assertContains('The "test3" extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); + + $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertContainsLang('PURGE', $crawler->filter('.ext_disabled')->eq(2)->text()); + + $this->assertContains('The "bar" extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); + } + + public function test_details() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); + + for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) + { + $text = $crawler->filter('dl')->eq($i)->text(); + + switch (true) + { + case (strpos($text, $this->lang('DISPLAY_NAME')) === 0): + $this->assertContains('phpBB Foo Extension', $text); + break; + + case (strpos($text, $this->lang('CLEAN_NAME')) === 0): + $this->assertContains('foo/example', $text); + break; + + case (strpos($text, $this->lang('DESCRIPTION')) === 0): + $this->assertContains('An example/sample extension to be used for testing purposes in phpBB Development.', $text); + break; + + case (strpos($text, $this->lang('VERSION')) === 0): + $this->assertContains('1.0.0', $text); + break; + + case (strpos($text, $this->lang('TIME')) === 0): + $this->assertContains('2012-02-15 01:01:01', $text); + break; + + case (strpos($text, $this->lang('LICENCE')) === 0): + $this->assertContains('GNU GPL v2', $text); + break; + + case (strpos($text, $this->lang('PHPBB_VERSION')) === 0): + $this->assertContains('3.1.0-dev', $text); + break; + + case (strpos($text, $this->lang('PHP_VERSION')) === 0): + $this->assertContains('>=5.3', $text); + break; + + case (strpos($text, $this->lang('AUTHOR_NAME')) === 0): + $this->assertContains('Nathan Guse', $text); + break; + + case (strpos($text, $this->lang('AUTHOR_EMAIL')) === 0): + $this->assertContains('email@phpbb.com', $text); + break; + + case (strpos($text, $this->lang('AUTHOR_HOMEPAGE')) === 0): + $this->assertContains('http://lithiumstudios.org', $text); + break; + + case (strpos($text, $this->lang('AUTHOR_ROLE')) === 0): + $this->assertContains('N/A', $text); + break; + } + } + } + + public function test_enable_pre() + { + // Foo is already enabled (error) + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_NOT_AVAILABLE', $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text()); + } + + public function test_disable_pre() + { + // Moo is not enabled (error) + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('EXTENSION_NOT_AVAILABLE', $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text()); + } + + public function test_purge_pre() + { + // test2 is not available (error) + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid); + $this->assertContains('The required file does not exist', $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid); + $this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text()); + } + + public function test_enable() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text()); + } + + public function test_disable() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text()); + } + + public function test_purge() + { + $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text()); + } +} \ No newline at end of file diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/foo/composer.json index 14af677dac..4b5150461f 100644 --- a/tests/extension/ext/foo/composer.json +++ b/tests/extension/ext/foo/composer.json @@ -8,7 +8,7 @@ "authors": [{ "name": "Nathan Guse", "username": "EXreaction", - "email": "nathaniel.guse@gmail.com", + "email": "email@phpbb.com", "homepage": "http://lithiumstudios.org", "role": "N/A" }], diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json new file mode 100644 index 0000000000..c91a5e027b --- /dev/null +++ b/tests/extension/ext/vendor/moo/composer.json @@ -0,0 +1,22 @@ +{ + "name": "moo/example", + "type": "phpbb3-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", + "licence": "GNU GPL v2", + "authors": [{ + "name": "Nathan Guse", + "username": "EXreaction", + "email": "email@phpbb.com", + "homepage": "http://lithiumstudios.org", + "role": "N/A" + }], + "require": { + "php": ">=5.3", + "phpbb": "3.1.0-dev" + }, + "extra": { + "display-name": "phpBB Moo Extension" + } +} diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 67630e9f36..d1e60ad268 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -11,7 +11,14 @@ class metadata_manager_test extends phpbb_database_test_case { protected $class_loader; protected $extension_manager; + + protected $cache; + protected $config; + protected $db; protected $phpbb_root_path; + protected $phpEx; + protected $template; + protected $user; public function getDataSet() { @@ -22,15 +29,30 @@ class metadata_manager_test extends phpbb_database_test_case { parent::setUp(); + $this->cache = new phpbb_mock_cache(); + $this->config = new phpbb_config(array( + 'version' => '3.1.0', + )); + $this->db = $this->new_dbal(); $this->phpbb_root_path = dirname(__FILE__) . '/'; + $this->phpEx = '.php'; + $this->user = new phpbb_user(); + + $this->template = new phpbb_template( + $this->phpbb_root_path, + $this->phpEx, + $this->config, + $this->user, + new phpbb_style_resource_locator() + ); $this->extension_manager = new phpbb_extension_manager( - $this->new_dbal(), - new phpbb_config(array()), + $this->db(), + $this->config, 'phpbb_ext', $this->phpbb_root_path, - '.php', - new phpbb_mock_cache + $this->phpEx, + $this->cache ); } @@ -39,21 +61,7 @@ class metadata_manager_test extends phpbb_database_test_case { $ext_name = 'bar'; - $manager = new phpbb_extension_metadata_manager_test( - $ext_name, - $this->new_dbal(), - $this->extension_manager, - $this->phpbb_root_path, - '.php', - new phpbb_template( - $this->phpbb_root_path, - '.php', - new phpbb_config(array()), - new phpbb_user(), - new phpbb_style_resource_locator() - ), - new phpbb_config(array()) - ); + $manager = $this->get_metadata_manager($ext_name); try { @@ -69,21 +77,7 @@ class metadata_manager_test extends phpbb_database_test_case { $ext_name = 'foo'; - $manager = new phpbb_extension_metadata_manager_test( - $ext_name, - $this->new_dbal(), - $this->extension_manager, - $this->phpbb_root_path, - '.php', - new phpbb_template( - $this->phpbb_root_path, - '.php', - new phpbb_config(array()), - new phpbb_user(), - new phpbb_style_resource_locator() - ), - new phpbb_config(array()) - ); + $manager = $this->get_metadata_manager($ext_name); try { @@ -103,23 +97,7 @@ class metadata_manager_test extends phpbb_database_test_case { $ext_name = 'validator'; - $manager = new phpbb_extension_metadata_manager_test( - $ext_name, - $this->new_dbal(), - $this->extension_manager, - $this->phpbb_root_path, - '.php', - new phpbb_template( - $this->phpbb_root_path, - '.php', - new phpbb_config(array()), - new phpbb_user(), - new phpbb_style_resource_locator() - ), - new phpbb_config(array( - 'version' => '3.1.0', - )) - ); + $manager = $this->get_metadata_manager($ext_name); // Non-existant data try @@ -358,6 +336,25 @@ class metadata_manager_test extends phpbb_database_test_case $this->fail($e); } } + + /** + * Get an instance of the metadata manager + * + * @param string $ext_name + * @return phpbb_extension_metadata_manager_test + */ + private function get_metadata_manager($ext_name) + { + return new phpbb_extension_metadata_manager_test( + $ext_name, + $this->new_dbal(), + $this->extension_manager, + $this->phpbb_root_path, + $this->phpEx, + $this->template, + $this->config + ); + } } class phpbb_extension_metadata_manager_test extends phpbb_extension_metadata_manager diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a1deeb2b63..6b4c0b6883 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -252,6 +252,48 @@ class phpbb_functional_test_case extends phpbb_test_case } } + /** + * Login to the ACP + * You must run login() before calling this. + */ + protected function admin_login() + { + $this->add_lang('acp/common'); + + // Requires login first! + if (empty($this->sid)) + { + $this->fail('$this->sid is empty. Make sure you call login() before admin_login()'); + return; + } + + $crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text()); + + $form = $crawler->selectButton($this->lang('LOGIN'))->form(); + + foreach ($form->getValues() as $field => $value) + { + if (strpos($field, 'password_') === 0) + { + $login = $this->client->submit($form, array('username' => 'admin', $field => 'admin')); + + $cookies = $this->cookieJar->all(); + + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie + foreach ($cookies as $cookie); + { + if (substr($cookie->getName(), -4) == '_sid') + { + $this->sid = $cookie->getValue(); + } + } + + break; + } + } + } + protected function add_lang($lang_file) { if (is_array($lang_file)) @@ -288,4 +330,16 @@ class phpbb_functional_test_case extends phpbb_test_case return call_user_func_array('sprintf', $args); } + + /** + * assertContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertContainsLang($needle, $haystack, $message = null) + { + $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 46feef550a..d10645a732 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -115,4 +115,112 @@ class phpbb_test_case_helpers return $config; } + + /** + * Recursive directory copying function + * + * @param string $source + * @param string $dest + * @return array list of files copied + */ + public function copy_dir($source, $dest) + { + $source = (substr($source, -1) == '/') ? $source : $source . '/'; + $dest = (substr($dest, -1) == '/') ? $dest : $dest . '/'; + + $copied_files = array(); + + if (!is_dir($dest)) + { + $this->makedirs($dest); + } + + $files = scandir($source); + foreach ($files as $file) + { + if ($file == '.' || $file == '..') + { + continue; + } + + if (is_dir($source . $file)) + { + $created_dir = false; + if (!is_dir($dest . $file)) + { + $created_dir = true; + $this->makedirs($dest . $file); + } + + $copied_files = array_merge($copied_files, self::copy_dir($source . $file, $dest . $file)); + + if ($created_dir) + { + $copied_files[] = $dest . $file; + } + } + else + { + if (!file_exists($dest . $file)) + { + copy($source . $file, $dest . $file); + + $copied_files[] = $dest . $file; + } + } + } + + return $copied_files; + } + + /** + * Remove files/directories that are listed in an array + * Designed for use with $this->copy_dir() + * + * @param array $file_list + */ + public function remove_files($file_list) + { + foreach ($file_list as $file) + { + if (is_dir($file)) + { + rmdir($file); + } + else + { + unlink($file); + } + } + } + + /** + * Empty directory (remove any subdirectories/files below) + * + * @param array $file_list + */ + public function empty_dir($path) + { + $path = (substr($path, -1) == '/') ? $path : $path . '/'; + + $files = scandir($path); + foreach ($files as $file) + { + if ($file == '.' || $file == '..') + { + continue; + } + + if (is_dir($path . $file)) + { + $this->empty_dir($path . $file); + + rmdir($path . $file); + } + else + { + unlink($path . $file); + } + } + } } From 47898cb37a1c1f517b5e6ae95427807ea5de11da Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 30 Jul 2012 13:36:51 -0500 Subject: [PATCH 519/666] [ticket/10631] Fix metadata_manager_test PHPBB3-10631 --- tests/extension/metadata_manager_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index d1e60ad268..801d4dbeca 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -47,7 +47,7 @@ class metadata_manager_test extends phpbb_database_test_case ); $this->extension_manager = new phpbb_extension_manager( - $this->db(), + $this->db, $this->config, 'phpbb_ext', $this->phpbb_root_path, @@ -347,7 +347,7 @@ class metadata_manager_test extends phpbb_database_test_case { return new phpbb_extension_metadata_manager_test( $ext_name, - $this->new_dbal(), + $this->db, $this->extension_manager, $this->phpbb_root_path, $this->phpEx, From dce04b2d03f93c9237b743afbcbd89fb6405f836 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 30 Jul 2012 19:30:49 -0500 Subject: [PATCH 520/666] [ticket/10631] Various front-end fixes (extensions manager) Add Back button from details Add cancel button from actions Correct language strings PHPBB3-10631 --- phpBB/adm/style/acp_ext_details.html | 2 ++ phpBB/adm/style/acp_ext_disable.html | 5 +++-- phpBB/adm/style/acp_ext_enable.html | 3 ++- phpBB/adm/style/acp_ext_purge.html | 5 +++-- phpBB/includes/acp/acp_extensions.php | 9 +++++++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html index 7408e88758..e927e9de18 100644 --- a/phpBB/adm/style/acp_ext_details.html +++ b/phpBB/adm/style/acp_ext_details.html @@ -2,6 +2,8 @@ + « {L_BACK} +

{L_EXTENSIONS_ADMIN}

diff --git a/phpBB/adm/style/acp_ext_disable.html b/phpBB/adm/style/acp_ext_disable.html index 1f0bbe14c8..7dc3f6ec97 100644 --- a/phpBB/adm/style/acp_ext_disable.html +++ b/phpBB/adm/style/acp_ext_disable.html @@ -5,7 +5,7 @@

{L_EXTENSIONS_ADMIN}

{L_EXTENSIONS_EXPLAIN}

-

{L_ENABLE_EXPLAIN}

+

{L_DISABLE_EXPLAIN}

@@ -15,7 +15,8 @@
{L_DISABLE} - + +
diff --git a/phpBB/adm/style/acp_ext_enable.html b/phpBB/adm/style/acp_ext_enable.html index 9f278bfbe0..3f7be2c847 100644 --- a/phpBB/adm/style/acp_ext_enable.html +++ b/phpBB/adm/style/acp_ext_enable.html @@ -15,7 +15,8 @@
{L_ENABLE} - + +
diff --git a/phpBB/adm/style/acp_ext_purge.html b/phpBB/adm/style/acp_ext_purge.html index 816fd872b9..00a58721cb 100644 --- a/phpBB/adm/style/acp_ext_purge.html +++ b/phpBB/adm/style/acp_ext_purge.html @@ -5,7 +5,7 @@

{L_EXTENSIONS_ADMIN}

{L_EXTENSIONS_EXPLAIN}

-

{L_ENABLE_EXPLAIN}

+

{L_PURGE_EXPLAIN}

@@ -15,7 +15,8 @@
{L_PURGE} - + +
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index c4d9f0c0e0..1a9d51505a 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -43,6 +43,13 @@ class acp_extensions $action = $request->variable('action', 'list'); $ext_name = $request->variable('ext_name', ''); + + // Cancel action + if ($request->is_set_post('cancel')) + { + $action = 'list'; + $ext_name = ''; + } // If they've specificed an extension, let's load the metadata manager and validate it. if ($ext_name) @@ -162,6 +169,8 @@ class acp_extensions // Output it to the template $md_manager->output_template_data(); + $template->assign_var('U_BACK', $this->u_action . '&action=list'); + $this->tpl_name = 'acp_ext_details'; break; } From 7b643fe8a5fd3b92bb4db9eacb27645417004709 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 5 Aug 2012 19:00:20 -0500 Subject: [PATCH 521/666] [ticket/10631] Make failure to meet ext enable requirements clearer Turn the blocks red on the details page if requirement is not met. Also changing a how the errors come up when trying to enable/disable an extension when they cannot be. PHPBB3-10631 --- phpBB/adm/style/acp_ext_details.html | 6 +++--- phpBB/adm/style/admin.css | 10 ++++++++++ phpBB/includes/acp/acp_extensions.php | 15 +++++++++----- phpBB/includes/extension/metadata_manager.php | 9 +++++++-- tests/extension/acp.php | 20 +++++++++---------- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html index e927e9de18..f477b452b7 100644 --- a/phpBB/adm/style/acp_ext_details.html +++ b/phpBB/adm/style/acp_ext_details.html @@ -3,7 +3,7 @@ « {L_BACK} - +

{L_EXTENSIONS_ADMIN}

@@ -50,13 +50,13 @@
{L_REQUIREMENTS} -
+ class="requirements_not_met">

{MD_REQUIRE_PHPBB}

-
+ class="requirements_not_met">

{MD_REQUIRE_PHP}

diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 08613de0dd..585707600d 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1718,3 +1718,13 @@ fieldset.permissions .padding { .phpinfo td, .phpinfo th, .phpinfo h2, .phpinfo h1 { text-align: left; } + +.requirements_not_met { + padding: 5px; + background-color: #BC2A4D; +} + +.requirements_not_met dt label, .requirements_not_met dd p { + color: #FFFFFF; + font-size: 1.4em; +} \ No newline at end of file diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 1a9d51505a..8dde6bc36c 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -43,7 +43,7 @@ class acp_extensions $action = $request->variable('action', 'list'); $ext_name = $request->variable('ext_name', ''); - + // Cancel action if ($request->is_set_post('cancel')) { @@ -79,9 +79,14 @@ class acp_extensions break; case 'enable_pre': - if (!$md_manager->validate_enable() || $phpbb_extension_manager->enabled($ext_name)) + if (!$md_manager->validate_enable()) { - trigger_error('EXTENSION_NOT_AVAILABLE'); + trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); + } + + if ($phpbb_extension_manager->enabled($ext_name)) + { + redirect($this->u_action); } $this->tpl_name = 'acp_ext_enable'; @@ -95,7 +100,7 @@ class acp_extensions case 'enable': if (!$md_manager->validate_enable()) { - trigger_error('EXTENSION_NOT_AVAILABLE'); + trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); } if ($phpbb_extension_manager->enable_step($ext_name)) @@ -115,7 +120,7 @@ class acp_extensions case 'disable_pre': if (!$phpbb_extension_manager->enabled($ext_name)) { - trigger_error('EXTENSION_NOT_AVAILABLE'); + redirect($this->u_action); } $this->tpl_name = 'acp_ext_disable'; diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index c7f52b7c02..8a68e464a7 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -320,8 +320,13 @@ class phpbb_extension_metadata_manager 'MD_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '', 'MD_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '', 'MD_LICENCE' => htmlspecialchars($this->metadata['licence']), - 'MD_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', - 'MD_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '', + + 'MD_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', + 'MD_REQUIRE_PHP_FAIL' => !$this->validate_require_php(), + + 'MD_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '', + 'MD_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(), + 'MD_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '', )); diff --git a/tests/extension/acp.php b/tests/extension/acp.php index c078a3f7b4..78a770343b 100644 --- a/tests/extension/acp.php +++ b/tests/extension/acp.php @@ -178,9 +178,11 @@ class acp_test extends phpbb_functional_test_case public function test_enable_pre() { - // Foo is already enabled (error) + // Foo is already enabled (redirect to list) $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NOT_AVAILABLE', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text()); @@ -188,9 +190,11 @@ class acp_test extends phpbb_functional_test_case public function test_disable_pre() { - // Moo is not enabled (error) + // Moo is not enabled (redirect to list) $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContainsLang('EXTENSION_NOT_AVAILABLE', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text()); + $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text()); $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); $this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text()); @@ -206,20 +210,14 @@ class acp_test extends phpbb_functional_test_case $this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text()); } - public function test_enable() + public function test_actions() { $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text()); - } - public function test_disable() - { $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text()); - } - public function test_purge() - { $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid); $this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text()); } From 323bbf9b523984a592dc17bf35d2bb91a435be1b Mon Sep 17 00:00:00 2001 From: Unknown Bliss Date: Fri, 17 Aug 2012 14:06:23 +0100 Subject: [PATCH 522/666] [ticket/10631] Adjust prefixes to be easier to understand PHPBB3-10631 --- phpBB/adm/style/acp_ext_details.html | 74 +++++++++---------- phpBB/adm/style/acp_ext_list.html | 4 +- phpBB/includes/acp/acp_extensions.php | 12 +-- phpBB/includes/extension/metadata_manager.php | 26 +++---- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html index f477b452b7..e7532691ad 100644 --- a/phpBB/adm/style/acp_ext_details.html +++ b/phpBB/adm/style/acp_ext_details.html @@ -8,57 +8,57 @@
{L_EXT_DETAILS} - +
-
-
{MD_DISPLAY_NAME}
+
+
{META_DISPLAY_NAME}
-
-
{MD_NAME}
+
+
{META_NAME}
- +
-
-

{MD_DESCRIPTION}

+
+

{META_DESCRIPTION}

-
-

{MD_VERSION}

+
+

{META_VERSION}

- +
-
-

{MD_HOMEPAGE}

+
+

{META_HOMEPAGE}

- +
-
-

{MD_TIME}

+
+

{META_TIME}

-
-

{MD_LICENCE}

+
+

{META_LICENCE}

- +
{L_REQUIREMENTS} - - class="requirements_not_met"> + + class="requirements_not_met">
-

{MD_REQUIRE_PHPBB}

+

{META_REQUIRE_PHPBB}

- - class="requirements_not_met"> + + class="requirements_not_met">
-

{MD_REQUIRE_PHP}

+

{META_REQUIRE_PHP}

@@ -66,32 +66,32 @@
{L_AUTHOR_INFORMATION} - +
-
-
{md_authors.AUTHOR_NAME}
+
+
{meta_authors.AUTHOR_NAME}
- +
-
-
{md_authors.AUTHOR_EMAIL}
+
+
{meta_authors.AUTHOR_EMAIL}
- +
-
-
{md_authors.AUTHOR_HOMEPAGE}
+
+
{meta_authors.AUTHOR_HOMEPAGE}
- +
-
{md_authors.AUTHOR_ROLE}
+
{meta_authors.AUTHOR_ROLE}
- +
diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index b654a80caa..53de0b4d12 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -24,7 +24,7 @@ - {enabled.EXT_NAME} + {enabled.META_DISPLAY_NAME} {L_DETAILS} @@ -42,7 +42,7 @@ - {disabled.EXT_NAME} + {disabled.META_DISPLAY_NAME} {L_DETAILS} diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 8dde6bc36c..5a537aaa42 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -196,7 +196,7 @@ class acp_extensions try { $this->template->assign_block_vars('enabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); @@ -209,7 +209,7 @@ class acp_extensions catch(phpbb_extension_exception $e) { $this->template->assign_block_vars('disabled', array( - 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); } } @@ -230,7 +230,7 @@ class acp_extensions try { $this->template->assign_block_vars('disabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); @@ -243,7 +243,7 @@ class acp_extensions catch(phpbb_extension_exception $e) { $this->template->assign_block_vars('disabled', array( - 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); } } @@ -266,7 +266,7 @@ class acp_extensions try { $this->template->assign_block_vars('disabled', array( - 'EXT_NAME' => $md_manager->get_metadata('display-name'), + 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), 'U_DETAILS' => $this->u_action . '&action=details&ext_name=' . urlencode($name), )); @@ -278,7 +278,7 @@ class acp_extensions catch(phpbb_extension_exception $e) { $this->template->assign_block_vars('disabled', array( - 'EXT_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), + 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), )); } } diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 8a68e464a7..1e3bbe48c9 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -313,26 +313,26 @@ class phpbb_extension_metadata_manager public function output_template_data() { $this->template->assign_vars(array( - 'MD_NAME' => htmlspecialchars($this->metadata['name']), - 'MD_TYPE' => htmlspecialchars($this->metadata['type']), - 'MD_DESCRIPTION' => (isset($this->metadata['description'])) ? htmlspecialchars($this->metadata['description']) : '', - 'MD_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '', - 'MD_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '', - 'MD_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '', - 'MD_LICENCE' => htmlspecialchars($this->metadata['licence']), + 'META_NAME' => htmlspecialchars($this->metadata['name']), + 'META_TYPE' => htmlspecialchars($this->metadata['type']), + 'META_DESCRIPTION' => (isset($this->metadata['description'])) ? htmlspecialchars($this->metadata['description']) : '', + 'META_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '', + 'META_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '', + 'META_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '', + 'META_LICENCE' => htmlspecialchars($this->metadata['licence']), - 'MD_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', - 'MD_REQUIRE_PHP_FAIL' => !$this->validate_require_php(), + 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '', + 'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(), - 'MD_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '', - 'MD_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(), + 'META_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '', + 'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(), - 'MD_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '', + 'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '', )); foreach ($this->metadata['authors'] as $author) { - $this->template->assign_block_vars('md_authors', array( + $this->template->assign_block_vars('meta_authors', array( 'AUTHOR_NAME' => htmlspecialchars($author['name']), 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '', 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '', From f05a175e3955d1dc1d2b85b9929ca4b30340ad4a Mon Sep 17 00:00:00 2001 From: Unknown Bliss Date: Fri, 17 Aug 2012 14:38:03 +0100 Subject: [PATCH 523/666] [ticket/10631] Fixing a few extension admin issues PHPBB3-10631 --- phpBB/includes/extension/metadata_manager.php | 3 --- tests/extension/ext/foo/composer.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 1e3bbe48c9..8c570830fe 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -60,7 +60,6 @@ class phpbb_extension_metadata_manager */ public function get_metadata($element = 'all') { - // TODO: Check ext_name exists and is an extension that exists $this->set_metadata_file(); // Fetch the metadata @@ -339,7 +338,5 @@ class phpbb_extension_metadata_manager 'AUTHOR_ROLE' => (isset($author['role'])) ? htmlspecialchars($author['role']) : '', )); } - - return; } } diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/foo/composer.json index 4b5150461f..744f7be625 100644 --- a/tests/extension/ext/foo/composer.json +++ b/tests/extension/ext/foo/composer.json @@ -4,7 +4,7 @@ "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", - "licence": "GNU GPL v2", + "licence": "GPL-2.0", "authors": [{ "name": "Nathan Guse", "username": "EXreaction", From a9b4f2a190777612762966476ac5af9ac2a78fd0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 27 Aug 2012 17:39:32 -0500 Subject: [PATCH 524/666] [ticket/10631] Some cleanup of the test cases The acp test case was not actually validating things correctly. Now is does PHPBB3-10631 --- tests/extension/acp.php | 73 ++++++--------- tests/extension/metadata_manager_test.php | 105 +++++++++++++++++----- 2 files changed, 109 insertions(+), 69 deletions(-) diff --git a/tests/extension/acp.php b/tests/extension/acp.php index 78a770343b..790df77c0d 100644 --- a/tests/extension/acp.php +++ b/tests/extension/acp.php @@ -119,59 +119,40 @@ class acp_test extends phpbb_functional_test_case { $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); + $validation = array( + 'DISPLAY_NAME' => 'phpBB Foo Extension', + 'CLEAN_NAME' => 'foo/example', + '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', + 'LICENCE' => 'GPL-2.0', + 'PHPBB_VERSION' => '3.1.0-dev', + 'PHP_VERSION' => '>=5.3', + 'AUTHOR_NAME' => 'Nathan Guse', + 'AUTHOR_EMAIL' => 'email@phpbb.com', + 'AUTHOR_HOMEPAGE' => 'http://lithiumstudios.org', + 'AUTHOR_ROLE' => 'N/A', + ); + for ($i = 0; $i < $crawler->filter('dl')->count(); $i++) { $text = $crawler->filter('dl')->eq($i)->text(); - switch (true) + $match = false; + + foreach ($validation as $language_key => $expected) { - case (strpos($text, $this->lang('DISPLAY_NAME')) === 0): - $this->assertContains('phpBB Foo Extension', $text); - break; + if (strpos($text, $this->lang($language_key)) === 0) + { + $match = true; - case (strpos($text, $this->lang('CLEAN_NAME')) === 0): - $this->assertContains('foo/example', $text); - break; + $this->assertContains($expected, $text); + } + } - case (strpos($text, $this->lang('DESCRIPTION')) === 0): - $this->assertContains('An example/sample extension to be used for testing purposes in phpBB Development.', $text); - break; - - case (strpos($text, $this->lang('VERSION')) === 0): - $this->assertContains('1.0.0', $text); - break; - - case (strpos($text, $this->lang('TIME')) === 0): - $this->assertContains('2012-02-15 01:01:01', $text); - break; - - case (strpos($text, $this->lang('LICENCE')) === 0): - $this->assertContains('GNU GPL v2', $text); - break; - - case (strpos($text, $this->lang('PHPBB_VERSION')) === 0): - $this->assertContains('3.1.0-dev', $text); - break; - - case (strpos($text, $this->lang('PHP_VERSION')) === 0): - $this->assertContains('>=5.3', $text); - break; - - case (strpos($text, $this->lang('AUTHOR_NAME')) === 0): - $this->assertContains('Nathan Guse', $text); - break; - - case (strpos($text, $this->lang('AUTHOR_EMAIL')) === 0): - $this->assertContains('email@phpbb.com', $text); - break; - - case (strpos($text, $this->lang('AUTHOR_HOMEPAGE')) === 0): - $this->assertContains('http://lithiumstudios.org', $text); - break; - - case (strpos($text, $this->lang('AUTHOR_ROLE')) === 0): - $this->assertContains('N/A', $text); - break; + if (!$match) + { + $this->fail('Unexpected field: "' . $text . '"'); } } } diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 801d4dbeca..9865f14314 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -93,7 +93,7 @@ class metadata_manager_test extends phpbb_database_test_case $this->assertEquals($metadata, $json); } - public function test_validator() + public function test_validator_non_existant() { $ext_name = 'validator'; @@ -103,37 +103,57 @@ class metadata_manager_test extends phpbb_database_test_case try { $manager->validate('name'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.'); try { $manager->validate('type'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.'); try { $manager->validate('licence'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.'); try { $manager->validate('version'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.'); try { $manager->validate_authors(); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.'); $manager->merge_metadata(array( 'authors' => array( @@ -144,10 +164,21 @@ class metadata_manager_test extends phpbb_database_test_case try { $manager->validate_authors(); - } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.'); + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.'); + } + } + + + public function test_validator_invalid() + { + $ext_name = 'validator'; + + $manager = $this->get_metadata_manager($ext_name); // Invalid data $manager->set_metadata(array( @@ -160,31 +191,53 @@ class metadata_manager_test extends phpbb_database_test_case try { $manager->validate('name'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Meta field \'name\' is invalid.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Meta field \'name\' is invalid.'); try { $manager->validate('type'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Meta field \'type\' is invalid.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Meta field \'type\' is invalid.'); try { $manager->validate('licence'); + + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.'); } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.'); try { $manager->validate('version'); - } - catch(phpbb_extension_exception $e) {} - $this->assertEquals((string) $e, 'Meta field \'version\' is invalid.'); + $this->fail('Exception not triggered'); + } + catch(phpbb_extension_exception $e) + { + $this->assertEquals((string) $e, 'Meta field \'version\' is invalid.'); + } + } + + public function test_validator_valid() + { + $ext_name = 'validator'; + + $manager = $this->get_metadata_manager($ext_name); // Valid data $manager->set_metadata(array( @@ -202,8 +255,14 @@ class metadata_manager_test extends phpbb_database_test_case { $this->fail($e); } + } + public function test_validator_requirements() + { + $ext_name = 'validator'; + + $manager = $this->get_metadata_manager($ext_name); // Too high of requirements $manager->merge_metadata(array( 'require' => array( From 7cffebbd4997f8a41a871f8ea6fe12dc0abc08c8 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 19 Aug 2012 17:24:38 -0400 Subject: [PATCH 525/666] [task/functional] Added posting tests (reply and new topic) PHPBB-10758 --- tests/functional/posting_test.php | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/functional/posting_test.php diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php new file mode 100644 index 0000000000..8d722361e0 --- /dev/null +++ b/tests/functional/posting_test.php @@ -0,0 +1,110 @@ +login(); + $this->add_lang('posting'); + + $crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text()); + + $hidden_fields = array(); + $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }); + + $test_message = 'This is a test topic posted by the testing framework.'; + $form_data = array( + 'subject' => 'Test Topic 1', + 'message' => $test_message, + 'post' => true, + 'f' => 2, + 'mode' => 'post', + 'sid' => $this->sid, + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) + // is not at least 2 seconds before submission, cancel the form + $form_data['lastclick'] = 0; + + // The add_form_key()/check_form_key() safeguards present a challenge because they require + // the timestamp created in add_form_key() to be sent as-is to check_form_key() but in check_form_key() + // it won't allow the current time to be the same as the timestamp it requires. + // As such, automated scripts like this one have to somehow bypass this without being able to change + // the timestamp. The only way I can think to do so is using sleep() + sleep(1); + + // I use a request because the form submission method does not allow you to send data that is not + // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) + // Instead, I send it as a request with the submit button "post" set to true. + $crawler = $this->client->request('POST', 'posting.php', $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid); + $this->assertContains($test_message, $crawler->filter('html')->text()); + } + + public function test_post_reply() + { + $this->login(); + $this->add_lang('posting'); + + $crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid); + $this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text()); + + $hidden_fields = array(); + $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }); + + $test_message = 'This is a test post posted by the testing framework.'; + $form_data = array( + 'subject' => 'Re: Test Topic 1', + 'message' => $test_message, + 'post' => true, + 't' => 2, + 'f' => 2, + 'mode' => 'reply', + 'sid' => $this->sid, + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // For reasoning behind the following two commands, see the test_post_new_topic() test + $form_data['lastclick'] = 0; + sleep(1); + + // Submit the post + $crawler = $this->client->request('POST', 'posting.php', $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid); + $this->assertContains($test_message, $crawler->filter('html')->text()); + } +} From 7dfe26dd781e7bd0438041058e2a1d95176e7836 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 1 Sep 2012 10:35:46 -0400 Subject: [PATCH 526/666] [task/functional] Allow tests to bypass certain restrictions with DEBUG_TEST PHPBB3-10758 --- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_install.php | 5 ++++- tests/functional/posting_test.php | 10 +--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5914831539..8e7e84bf83 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2811,7 +2811,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg $diff = time() - $creation_time; // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)... - if ($diff && ($diff <= $timespan || $timespan === -1)) + if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1)) { $token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : ''; $key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid); diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 89dfb7cd2f..2e10db6b24 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -551,10 +551,12 @@ function adjust_language_keys_callback($matches) * @param string $dbms The name of the DBAL class to use * @param array $load_extensions Array of additional extensions that should be loaded * @param bool $debug If the debug constants should be enabled by default or not +* @param bool $debug_test If the DEBUG_TEST constant should be added +* NOTE: Only for use within the testing framework * * @return string The output to write to the file */ -function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false) +function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false) { $load_extensions = implode(',', $load_extensions); @@ -584,6 +586,7 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = { $config_data .= "@define('DEBUG', true);\n"; $config_data .= "@define('DEBUG_EXTRA', true);\n"; + $config_data .= "@define('DEBUG_TEST', true);\n"; } else { diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8d722361e0..f54a3591b2 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -47,13 +47,6 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case // is not at least 2 seconds before submission, cancel the form $form_data['lastclick'] = 0; - // The add_form_key()/check_form_key() safeguards present a challenge because they require - // the timestamp created in add_form_key() to be sent as-is to check_form_key() but in check_form_key() - // it won't allow the current time to be the same as the timestamp it requires. - // As such, automated scripts like this one have to somehow bypass this without being able to change - // the timestamp. The only way I can think to do so is using sleep() - sleep(1); - // I use a request because the form submission method does not allow you to send data that is not // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. @@ -96,9 +89,8 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case } } - // For reasoning behind the following two commands, see the test_post_new_topic() test + // For reasoning behind the following command, see the test_post_new_topic() test $form_data['lastclick'] = 0; - sleep(1); // Submit the post $crawler = $this->client->request('POST', 'posting.php', $form_data); From 4dd1bbc5879ae5fcae04341a9152e0366ed68bdd Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 1 Sep 2012 10:53:01 -0400 Subject: [PATCH 527/666] [task/functional] Fixed DEBUG_TEST related issues PHPBB3-10758 --- phpBB/includes/functions_install.php | 6 +++++- tests/test_framework/phpbb_functional_test_case.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 2e10db6b24..eae136808c 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -586,7 +586,6 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = { $config_data .= "@define('DEBUG', true);\n"; $config_data .= "@define('DEBUG_EXTRA', true);\n"; - $config_data .= "@define('DEBUG_TEST', true);\n"; } else { @@ -594,6 +593,11 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = $config_data .= "// @define('DEBUG_EXTRA', true);\n"; } + if ($debug_test) + { + $config_data .= "@define('DEBUG_TEST', true);\n"; + } + return $config_data; } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 2423299b7c..d35913e415 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -140,7 +140,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->do_request('create_table', $data); $this->do_request('config_file', $data); - file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true)); + file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true)); $this->do_request('final', $data); copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); From 0c35ee2769d3945f25275d5ee7a130b7596d289f Mon Sep 17 00:00:00 2001 From: "Michael C." Date: Sat, 1 Sep 2012 17:32:59 +0200 Subject: [PATCH 528/666] [ticket/10631] Fix a spelling typo PHPBB3-10631 --- phpBB/includes/acp/acp_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 5a537aaa42..a0bcf62ecc 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -51,7 +51,7 @@ class acp_extensions $ext_name = ''; } - // If they've specificed an extension, let's load the metadata manager and validate it. + // If they've specified an extension, let's load the metadata manager and validate it. if ($ext_name) { $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, ".$phpEx", $template, $config); From ed052290a70ae3a42f9e7c59f3dca95aba0c0ac7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 1 Sep 2012 17:40:19 +0200 Subject: [PATCH 529/666] [ticket/11082] Remove executable permission from redis driver file PHPBB3-11082 --- phpBB/includes/cache/driver/redis.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 phpBB/includes/cache/driver/redis.php diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php old mode 100755 new mode 100644 From 8741bcdaf5bb815a228188b4dfe4e3beebcca3b3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 1 Sep 2012 17:51:27 +0200 Subject: [PATCH 530/666] [ticket/11083] Mark memory cache driver as abstract PHPBB3-11083 --- phpBB/includes/cache/driver/memory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index 92971c6cb2..e0771ab1d3 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * ACM Abstract Memory Class * @package acm */ -class phpbb_cache_driver_memory extends phpbb_cache_driver_base +abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base { var $key_prefix; From 7ed7b19a1f1c3732b561ec3c8a4a39f115b5e6ac Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 1 Sep 2012 19:12:57 +0200 Subject: [PATCH 531/666] [feature/dic] Remove unneeded newline PHPBB3-10739 --- phpBB/common.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index 6ca495a7e3..281eb88c4d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -86,7 +86,6 @@ require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); From 282a80077d4630ba59043fffe59e8a7ce8619ecb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 1 Sep 2012 19:17:01 +0200 Subject: [PATCH 532/666] [feature/dic] Spaces to tabs, add useless docblocks Fully documents the constructors of the processors and the cron tasks. PHPBB3-10739 --- .../cron/task/core/prune_all_forums.php | 8 ++ phpBB/includes/cron/task/core/prune_forum.php | 8 ++ phpBB/includes/cron/task/core/queue.php | 7 ++ phpBB/includes/cron/task/core/tidy_cache.php | 6 ++ .../includes/cron/task/core/tidy_database.php | 7 ++ phpBB/includes/cron/task/core/tidy_search.php | 10 +++ .../includes/cron/task/core/tidy_sessions.php | 6 ++ .../includes/cron/task/core/tidy_warnings.php | 7 ++ phpBB/includes/di/processor/config.php | 82 +++++++++++-------- phpBB/includes/di/processor/ext.php | 47 +++++++---- phpBB/includes/di/processor/interface.php | 9 +- 11 files changed, 143 insertions(+), 54 deletions(-) diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php index 5164087b68..252e16e57d 100644 --- a/phpBB/includes/cron/task/core/prune_all_forums.php +++ b/phpBB/includes/cron/task/core/prune_all_forums.php @@ -31,6 +31,14 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base protected $config; protected $db; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_config $config The config + * @param dbal $db The db connection + */ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php index 8bb13ffe36..41d60af921 100644 --- a/phpBB/includes/cron/task/core/prune_forum.php +++ b/phpBB/includes/cron/task/core/prune_forum.php @@ -41,6 +41,14 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p */ protected $forum_data; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_config $config The config + * @param dbal $db The db connection + */ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php index 3278ce9d76..c765660906 100644 --- a/phpBB/includes/cron/task/core/queue.php +++ b/phpBB/includes/cron/task/core/queue.php @@ -26,6 +26,13 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base protected $php_ext; protected $config; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_config $config The config + */ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php index 573243c166..6017eea561 100644 --- a/phpBB/includes/cron/task/core/tidy_cache.php +++ b/phpBB/includes/cron/task/core/tidy_cache.php @@ -25,6 +25,12 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base protected $config; protected $cache; + /** + * Constructor. + * + * @param phpbb_config $config The config + * @param phpbb_cache_driver_interface $cache The cache driver + */ public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache) { $this->config = $config; diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php index c9f81cbb51..1d256f964f 100644 --- a/phpBB/includes/cron/task/core/tidy_database.php +++ b/phpBB/includes/cron/task/core/tidy_database.php @@ -26,6 +26,13 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base protected $php_ext; protected $config; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_config $config The config + */ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php index 00af293b6d..2e5f3d79d5 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/includes/cron/task/core/tidy_search.php @@ -31,6 +31,16 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base protected $db; protected $user; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_auth $auth The auth + * @param phpbb_config $config The config + * @param dbal $db The db connection + * @param phpbb_user $user The user + */ public function __construct($phpbb_root_path, $php_ext, phpbb_auth $auth, phpbb_config $config, dbal $db, phpbb_user $user) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php index 695a537274..13531aa30b 100644 --- a/phpBB/includes/cron/task/core/tidy_sessions.php +++ b/phpBB/includes/cron/task/core/tidy_sessions.php @@ -25,6 +25,12 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base protected $config; protected $user; + /** + * Constructor. + * + * @param phpbb_config $config The config + * @param phpbb_user $user The user + */ public function __construct(phpbb_config $config, phpbb_user $user) { $this->config = $config; diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php index acffd12052..8dd0674fe5 100644 --- a/phpBB/includes/cron/task/core/tidy_warnings.php +++ b/phpBB/includes/cron/task/core/tidy_warnings.php @@ -28,6 +28,13 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base protected $php_ext; protected $config; + /** + * Constructor. + * + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + * @param phpbb_config $config The config + */ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config) { $this->phpbb_root_path = $phpbb_root_path; diff --git a/phpBB/includes/di/processor/config.php b/phpBB/includes/di/processor/config.php index 1a5ec15854..22b6252a6d 100644 --- a/phpBB/includes/di/processor/config.php +++ b/phpBB/includes/di/processor/config.php @@ -12,51 +12,65 @@ */ if (!defined('IN_PHPBB')) { - exit; + exit; } use Symfony\Component\DependencyInjection\ContainerBuilder; +/** +* Configure the container for phpBB's services though +* user-defined parameters defined in the config.php file. +*/ class phpbb_di_processor_config implements phpbb_di_processor_interface { - private $config_file; - private $phpbb_root_path; - private $php_ext; + private $config_file; + private $phpbb_root_path; + private $php_ext; - public function __construct($config_file, $phpbb_root_path, $php_ext) - { - $this->config_file = $config_file; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } + /** + * Constructor. + * + * @param string $config_file The config file + * @param string $phpbb_root_path The root path + * @param string $php_ext The PHP extension + */ + public function __construct($config_file, $phpbb_root_path, $php_ext) + { + $this->config_file = $config_file; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + } - public function process(ContainerBuilder $container) - { - require $this->config_file; + /** + * @inheritdoc + */ + public function process(ContainerBuilder $container) + { + require $this->config_file; - $container->setParameter('core.root_path', $this->phpbb_root_path); - $container->setParameter('core.php_ext', $this->php_ext); + $container->setParameter('core.root_path', $this->phpbb_root_path); + $container->setParameter('core.php_ext', $this->php_ext); - $container->setParameter('core.table_prefix', $table_prefix); - $container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type)); - $container->setParameter('dbal.driver.class', 'dbal_'.$dbms); - $container->setParameter('dbal.dbhost', $dbhost); - $container->setParameter('dbal.dbuser', $dbuser); - $container->setParameter('dbal.dbpasswd', $dbpasswd); - $container->setParameter('dbal.dbname', $dbname); - $container->setParameter('dbal.dbport', $dbport); - $container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK); + $container->setParameter('core.table_prefix', $table_prefix); + $container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type)); + $container->setParameter('dbal.driver.class', 'dbal_'.$dbms); + $container->setParameter('dbal.dbhost', $dbhost); + $container->setParameter('dbal.dbuser', $dbuser); + $container->setParameter('dbal.dbpasswd', $dbpasswd); + $container->setParameter('dbal.dbname', $dbname); + $container->setParameter('dbal.dbport', $dbport); + $container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK); - $container->set('container', $container); - } + $container->set('container', $container); + } - protected function fix_acm_type($acm_type) - { - if (preg_match('#^[a-z]+$#', $acm_type)) - { - return 'phpbb_cache_driver_'.$acm_type; - } + protected function fix_acm_type($acm_type) + { + if (preg_match('#^[a-z]+$#', $acm_type)) + { + return 'phpbb_cache_driver_'.$acm_type; + } - return $acm_type; - } + return $acm_type; + } } diff --git a/phpBB/includes/di/processor/ext.php b/phpBB/includes/di/processor/ext.php index 04a586a086..e69a3d73b3 100644 --- a/phpBB/includes/di/processor/ext.php +++ b/phpBB/includes/di/processor/ext.php @@ -12,32 +12,43 @@ */ if (!defined('IN_PHPBB')) { - exit; + exit; } use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +/** +* Load the service configurations from all extensions into the container. +*/ class phpbb_di_processor_ext implements phpbb_di_processor_interface { - private $extension_manager; + private $extension_manager; - public function __construct($extension_manager) - { - $this->extension_manager = $extension_manager; - } + /** + * Constructor. + * + * @param string $extension_manager The extension manager + */ + public function __construct($extension_manager) + { + $this->extension_manager = $extension_manager; + } - public function process(ContainerBuilder $container) - { - $enabled_exts = $this->extension_manager->all_enabled(); - foreach ($enabled_exts as $name => $path) - { - if (file_exists($path . '/config/services.yml')) - { - $loader = new YamlFileLoader($container, new FileLocator($path . '/config')); - $loader->load('services.yml'); - } - } - } + /** + * @inheritdoc + */ + public function process(ContainerBuilder $container) + { + $enabled_exts = $this->extension_manager->all_enabled(); + foreach ($enabled_exts as $name => $path) + { + if (file_exists($path . '/config/services.yml')) + { + $loader = new YamlFileLoader($container, new FileLocator($path . '/config')); + $loader->load('services.yml'); + } + } + } } diff --git a/phpBB/includes/di/processor/interface.php b/phpBB/includes/di/processor/interface.php index 51bd85a076..b8563791cc 100644 --- a/phpBB/includes/di/processor/interface.php +++ b/phpBB/includes/di/processor/interface.php @@ -12,12 +12,17 @@ */ if (!defined('IN_PHPBB')) { - exit; + exit; } use Symfony\Component\DependencyInjection\ContainerBuilder; interface phpbb_di_processor_interface { - public function process(ContainerBuilder $container); + /** + * Mutate the container. + * + * @param ContainerBuilder $container The container + */ + public function process(ContainerBuilder $container); } From 81f7f28cc33d896973c2912097103ea84fa14114 Mon Sep 17 00:00:00 2001 From: Unknown Bliss Date: Sat, 1 Sep 2012 21:30:35 +0100 Subject: [PATCH 533/666] [ticket/10631] Removing un-needed TODOs that are no longer needed. PHPBB3-10631 --- phpBB/includes/extension/metadata_manager.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 8c570830fe..ea85bd3c4e 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -95,7 +95,6 @@ class phpbb_extension_metadata_manager return ($this->validate('name')) ? $this->metadata['name'] : false; } break; - // TODO: Add remaining cases as needed } } @@ -153,9 +152,6 @@ class phpbb_extension_metadata_manager */ private function clean_metadata_array() { -// TODO: Remove all parts of the array we don't want or shouldn't be there due to nub mod authors -// $this->metadata = $metadata_finished; - return $this->metadata; } From b3cd5a649be62f175de651a16ae02c5f709ca2f4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 13:32:33 -0500 Subject: [PATCH 534/666] [ticket/8713] Do not trim login inputs Create a function to request variables which are not trimmed. All requests for passwords (except forum passwords) now use the untrimmed request function. PHPBB3-8713 --- phpBB/includes/acp/acp_language.php | 6 +- phpBB/includes/acp/acp_users.php | 6 +- phpBB/includes/functions.php | 4 +- phpBB/includes/request/request.php | 63 +++++++++++++++++++++ phpBB/includes/request/type_cast_helper.php | 22 +++++-- phpBB/includes/ucp/ucp_profile.php | 6 +- phpBB/includes/ucp/ucp_register.php | 4 +- phpBB/install/install_update.php | 4 +- tests/request/type_cast_helper_test.php | 10 ++++ 9 files changed, 104 insertions(+), 21 deletions(-) diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 2b19f93c75..87cf605d8e 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -100,11 +100,11 @@ class acp_language switch ($method) { case 'ftp': - $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; case 'ftp_fsock': - $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; default: @@ -404,7 +404,7 @@ class acp_language trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR); } - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); if (($result = $transfer->open_session()) !== true) { diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b54257b04a..b9958ed0f1 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -32,7 +32,7 @@ class acp_users { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; - global $phpbb_dispatcher; + global $phpbb_dispatcher, $request; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; @@ -770,8 +770,8 @@ class acp_users 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)), 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), 'email' => strtolower(request_var('user_email', $user_row['user_email'])), - 'new_password' => request_var('new_password', '', true), - 'password_confirm' => request_var('password_confirm', '', true), + 'new_password' => $request->untrimed_variable('new_password', '', true), + 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), ); // Validation data - we do not check the password complexity setting here diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 834f57a38b..1cdda60855 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3044,11 +3044,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa trigger_error('NO_AUTH_ADMIN'); } - $password = request_var('password_' . $credential, '', true); + $password = $request->untrimed_variable('password_' . $credential, '', true); } else { - $password = request_var('password', '', true); + $password = $request->untrimed_variable('password', '', true); } $username = request_var('username', '', true); diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index 4e425dbd27..747ca09624 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -242,6 +242,69 @@ class phpbb_request implements phpbb_request_interface return $var; } + /** + * Get a variable, but without trimming strings + * Same functionality as variable(), except does not run trim() on strings + * All variables in GET or POST requests should be retrieved through this function to maximise security. + * + * @param string|array $var_name The form variable's name from which data shall be retrieved. + * If the value is an array this may be an array of indizes which will give + * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") + * then specifying array("var", 1) as the name will return "a". + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies which super global should be used + * + * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the + * the same as that of $default. If the variable is not set $default is returned. + */ + public function untrimed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST) + { + $path = false; + + // deep direct access to multi dimensional arrays + if (is_array($var_name)) + { + $path = $var_name; + // make sure at least the variable name is specified + if (empty($path)) + { + return (is_array($default)) ? array() : $default; + } + // the variable name is the first element on the path + $var_name = array_shift($path); + } + + if (!isset($this->input[$super_global][$var_name])) + { + return (is_array($default)) ? array() : $default; + } + $var = $this->input[$super_global][$var_name]; + + if ($path) + { + // walk through the array structure and find the element we are looking for + foreach ($path as $key) + { + if (is_array($var) && isset($var[$key])) + { + $var = $var[$key]; + } + else + { + return (is_array($default)) ? array() : $default; + } + } + } + + $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, false); + + return $var; + } + /** * Shortcut method to retrieve SERVER variables. * diff --git a/phpBB/includes/request/type_cast_helper.php b/phpBB/includes/request/type_cast_helper.php index 561e8fc251..d3b94aac5a 100644 --- a/phpBB/includes/request/type_cast_helper.php +++ b/phpBB/includes/request/type_cast_helper.php @@ -93,15 +93,23 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i * @param mixed $type The variable type. Will be used with {@link settype()} * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. + * @param bool $trim Indicates whether string values will be be parsed with trim() + * Default is true */ - public function set_var(&$result, $var, $type, $multibyte = false) + public function set_var(&$result, $var, $type, $multibyte = false, $trim = true) { settype($var, $type); $result = $var; if ($type == 'string') { - $result = trim(str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result)); + $result = str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result); + + if ($trim) + { + $result = trim($result); + } + $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8'); if ($multibyte) @@ -141,8 +149,10 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i * @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to * be replaced with question marks. + * @param bool $trim Indicates whether string values will be be parsed with trim() + * Default is true */ - public function recursive_set_var(&$var, $default, $multibyte) + public function recursive_set_var(&$var, $default, $multibyte, $trim = true) { if (is_array($var) !== is_array($default)) { @@ -153,7 +163,7 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i if (!is_array($default)) { $type = gettype($default); - $this->set_var($var, $var, $type, $multibyte); + $this->set_var($var, $var, $type, $multibyte, $trim); } else { @@ -174,9 +184,9 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i foreach ($_var as $k => $v) { - $this->set_var($k, $k, $key_type, $multibyte, $multibyte); + $this->set_var($k, $k, $key_type, $multibyte, $trim); - $this->recursive_set_var($v, $default_value, $multibyte); + $this->recursive_set_var($v, $default_value, $multibyte, $trim); $var[$k] = $v; } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 2ac82fb52f..68d5dd5d65 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -46,9 +46,9 @@ class ucp_profile $data = array( 'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)), 'email' => strtolower(request_var('email', $user->data['user_email'])), - 'new_password' => request_var('new_password', '', true), - 'cur_password' => request_var('cur_password', '', true), - 'password_confirm' => request_var('password_confirm', '', true), + 'new_password' => $request->untrimed_variable('new_password', '', true), + 'cur_password' => $request->untrimed_variable('cur_password', '', true), + 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), ); add_form_key('ucp_reg_details'); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 6ce53a79ab..6fab189a99 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -170,8 +170,8 @@ class ucp_register $data = array( 'username' => utf8_normalize_nfc(request_var('username', '', true)), - 'new_password' => request_var('new_password', '', true), - 'password_confirm' => request_var('password_confirm', '', true), + 'new_password' => $request->untrimed_variable('new_password', '', true), + 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', $timezone), diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 88b00f1cf1..4b5a23e497 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,7 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +948,7 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $transfer->open_session(); } diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index d553d5b8cd..f7e5cd873e 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -48,4 +48,14 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $this->assertEquals($expected, $data); } + + public function test_untrimmed_strings() + { + $data = array(' eviL<3 '); + $expected = array(' eviL<3 '); + + $this->type_cast_helper->recursive_set_var($data, '', true, false); + + $this->assertEquals($expected, $data); + } } From 815cc4a9a3fa8c633b55925eb77f9f3bdbb5de04 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 18:23:36 -0500 Subject: [PATCH 535/666] [ticket/8796] Make function markread obey the $post_time argument Also do a little cleanup of the markread function PHPBB3-8796 --- phpBB/includes/functions.php | 71 ++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 834f57a38b..53f48cb8a7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1280,6 +1280,10 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) * Marks a topic/forum as read * Marks a topic as posted to * +* @param string $mode (all, topics, topic, post) +* @param int|bool $forum_id Used in all, topics, and topic mode +* @param int|bool $topic_id Used in topic and post mode +* @param int $post_time 0 means current time(), otherwise to set a specific mark time * @param int $user_id can only be used with $mode == 'post' */ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) @@ -1287,6 +1291,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ global $db, $user, $config; global $request; + $post_time = ($post_time === 0) ? time() : (int) $post_time; + if ($mode == 'all') { if ($forum_id === false || !sizeof($forum_id)) @@ -1294,9 +1300,22 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if ($config['load_db_lastread'] && $user->data['is_registered']) { // Mark all forums read (index page) - $db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}"); - $db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}"); - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}"); + $tables = array(TOPICS_TRACK_TABLE, FORUMS_TRACK_TABLE); + foreach ($tables as $table) + { + $sql = 'DELETE FROM ' . $table . " + WHERE user_id = {$user->data['user_id']} + AND mark_time < . $post_time"; + $db->sql_query($sql); + } + + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lastmark = $post_time + WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time"; + $db->sql_query($sql); + + $user->data['user_lastmark'] = $post_time; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { @@ -1306,16 +1325,22 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ unset($tracking_topics['tf']); unset($tracking_topics['t']); unset($tracking_topics['f']); - $tracking_topics['l'] = base_convert(time() - $config['board_startdate'], 10, 36); + $tracking_topics['l'] = base_convert($post_time - $config['board_startdate'], 10, 36); - $user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000); + $user->set_cookie('track', tracking_serialize($tracking_topics), $post_time + 31536000); $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking_topics), phpbb_request_interface::COOKIE); unset($tracking_topics); if ($user->data['is_registered']) { - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}"); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lastmark = $post_time + WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time"; + $db->sql_query($sql); + + $user->data['user_lastmark'] = $post_time; } } } @@ -1337,12 +1362,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ { $sql = 'DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time AND " . $db->sql_in_set('forum_id', $forum_id); $db->sql_query($sql); $sql = 'SELECT forum_id FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time AND " . $db->sql_in_set('forum_id', $forum_id); $result = $db->sql_query($sql); @@ -1355,9 +1382,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if (sizeof($sql_update)) { - $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . ' - SET mark_time = ' . time() . " + $sql = 'UPDATE ' . FORUMS_TRACK_TABLE . " + SET mark_time = $post_time WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time AND " . $db->sql_in_set('forum_id', $sql_update); $db->sql_query($sql); } @@ -1370,7 +1398,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $sql_ary[] = array( 'user_id' => (int) $user->data['user_id'], 'forum_id' => (int) $f_id, - 'mark_time' => time() + 'mark_time' => $post_time, ); } @@ -1401,7 +1429,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ unset($tracking['f'][$f_id]); } - $tracking['f'][$f_id] = base_convert(time() - $config['board_startdate'], 10, 36); + $tracking['f'][$f_id] = base_convert($post_time - $config['board_startdate'], 10, 36); } if (isset($tracking['tf']) && empty($tracking['tf'])) @@ -1409,7 +1437,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ unset($tracking['tf']); } - $user->set_cookie('track', tracking_serialize($tracking), time() + 31536000); + $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_interface::COOKIE); unset($tracking); @@ -1426,9 +1454,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if ($config['load_db_lastread'] && $user->data['is_registered']) { - $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . ' - SET mark_time = ' . (($post_time) ? $post_time : time()) . " + $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . " + SET mark_time = $post_time WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time AND topic_id = $topic_id"; $db->sql_query($sql); @@ -1441,7 +1470,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ 'user_id' => (int) $user->data['user_id'], 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, - 'mark_time' => ($post_time) ? (int) $post_time : time(), + 'mark_time' => $post_time, ); $db->sql_query('INSERT INTO ' . TOPICS_TRACK_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); @@ -1461,7 +1490,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $tracking['tf'][$forum_id][$topic_id36] = true; } - $post_time = ($post_time) ? $post_time : time(); $tracking['t'][$topic_id36] = base_convert($post_time - $config['board_startdate'], 10, 36); // If the cookie grows larger than 10000 characters we will remove the smallest value @@ -1496,8 +1524,13 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if ($user->data['is_registered']) { - $user->data['user_lastmark'] = intval(base_convert(max($time_keys) + $config['board_startdate'], 36, 10)); - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . $user->data['user_lastmark'] . " WHERE user_id = {$user->data['user_id']}"); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lastmark = $post_time + WHERE user_id = {$user->data['user_id']} + AND mark_time < $post_time"; + $db->sql_query($sql); + + $user->data['user_lastmark'] = $post_time; } else { @@ -1505,7 +1538,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } } - $user->set_cookie('track', tracking_serialize($tracking), time() + 31536000); + $user->set_cookie('track', tracking_serialize($tracking), $post_time + 31536000); $request->overwrite($config['cookie_name'] . '_track', tracking_serialize($tracking), phpbb_request_interface::COOKIE); } @@ -1527,7 +1560,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $sql_ary = array( 'user_id' => (int) $use_user_id, 'topic_id' => (int) $topic_id, - 'topic_posted' => 1 + 'topic_posted' => 1, ); $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); From b9308329cf3c0e6844a35f2d274423c2640887db Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 18:37:54 -0500 Subject: [PATCH 536/666] [ticket/8796] Revert changes to $user->data['lastmark'] The earlier change might change the way some things work (after looking at viewtopic) and I'd rather not risk introducing new bugs, so I'm going to revert those changes to be safe. PHPBB3-8796 --- phpBB/includes/functions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 53f48cb8a7..26b73e20fe 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1314,8 +1314,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ WHERE user_id = {$user->data['user_id']} AND mark_time < $post_time"; $db->sql_query($sql); - - $user->data['user_lastmark'] = $post_time; } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { @@ -1339,8 +1337,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ WHERE user_id = {$user->data['user_id']} AND mark_time < $post_time"; $db->sql_query($sql); - - $user->data['user_lastmark'] = $post_time; } } } @@ -1524,13 +1520,13 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ if ($user->data['is_registered']) { + $user->data['user_lastmark'] = intval(base_convert(max($time_keys) + $config['board_startdate'], 36, 10)); + $sql = 'UPDATE ' . USERS_TABLE . " SET user_lastmark = $post_time WHERE user_id = {$user->data['user_id']} AND mark_time < $post_time"; $db->sql_query($sql); - - $user->data['user_lastmark'] = $post_time; } else { From 9cba0b5263a8dcf0ff4cbfd6db2b37cd0cce55f1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 18:51:29 -0500 Subject: [PATCH 537/666] [ticket/8796] Mark read links updated to include time() in url Submitting the current time() allows us to mark only the topics and forums read up until a certain time (when the user loaded the page). This means that any new posts or topics posted between when the user opened the page and clicked the link are still shown as unread. PHPBB3-8796 --- phpBB/includes/functions_display.php | 6 +++--- phpBB/index.php | 2 +- phpBB/viewforum.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 881c95907b..e9c7143473 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -59,7 +59,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod if (check_link_hash(request_var('hash', ''), 'global')) { - markread('all'); + markread('all', false, false, request_var('mark_time', 0)); trigger_error( $user->lang['FORUMS_MARKED'] . '

' . @@ -309,7 +309,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { - markread('topics', $forum_ids); + markread('topics', $forum_ids, false, request_var('mark_time', 0)); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); @@ -551,7 +551,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } $template->assign_vars(array( - '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') : '', + '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()) : '', 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), diff --git a/phpBB/index.php b/phpBB/index.php index 0ac8034d7f..66e1b2114b 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -167,7 +167,7 @@ $template->assign_vars(array( 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), 'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false, - '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') : '', + '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_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '') ); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 03c2bb286f..83e5d4caa5 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -176,7 +176,7 @@ if ($mark_read == 'topics') $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { - markread('topics', array($forum_id)); + markread('topics', array($forum_id), false, request_var('mark_time', 0)); } $redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); meta_refresh(3, $redirect_url); @@ -340,7 +340,7 @@ $template->assign_vars(array( 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&f=' . $forum_id) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start == 0) ? '' : "&start=$start")), - '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") : '', + '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()) : '', )); // Grab icons From fccbf09e4aa9034afba5d5992d773b209f59bba7 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 3 Sep 2012 18:58:38 -0500 Subject: [PATCH 538/666] [ticket/8796] Fix a few issues with the previous commits Fix an SQL error and the redirect url generated PHPBB3-8796 --- phpBB/includes/functions.php | 6 +++--- phpBB/includes/functions_display.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 26b73e20fe..13cb15d73d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1305,14 +1305,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ { $sql = 'DELETE FROM ' . $table . " WHERE user_id = {$user->data['user_id']} - AND mark_time < . $post_time"; + AND mark_time < $post_time"; $db->sql_query($sql); } $sql = 'UPDATE ' . USERS_TABLE . " SET user_lastmark = $post_time WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; + AND user_lastmark < $post_time"; $db->sql_query($sql); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) @@ -1335,7 +1335,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $sql = 'UPDATE ' . USERS_TABLE . " SET user_lastmark = $post_time WHERE user_id = {$user->data['user_id']} - AND mark_time < $post_time"; + AND user_lastmark < $post_time"; $db->sql_query($sql); } } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e9c7143473..39ec8445c5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -54,7 +54,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod // Handle marking everything read if ($mark_read == 'all') { - $redirect = build_url(array('mark', 'hash')); + $redirect = build_url(array('mark', 'hash', 'mark_time')); meta_refresh(3, $redirect); if (check_link_hash(request_var('hash', ''), 'global')) @@ -305,7 +305,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod // Handle marking posts if ($mark_read == 'forums') { - $redirect = build_url(array('mark', 'hash')); + $redirect = build_url(array('mark', 'hash', 'mark_time')); $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { From c93b3827dc0644ea4aece1af661224aaa68a4cae Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 6 Sep 2012 18:27:49 -0500 Subject: [PATCH 539/666] [ticket/11092] phpbb_gen_download_links strict standards errors Two strict standards errors in phpbb_gen_download_links PHPBB3-11092 --- phpBB/includes/functions_compress.php | 4 +++- phpBB/includes/functions_display.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 8e07e6d1b8..4675394633 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -159,8 +159,10 @@ class compress /** * Return available methods + * + * @return array Array of strings of available compression methods (.tar, .tar.gz, .zip, etc.) */ - function methods() + public static function methods() { $methods = array('.tar'); $available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib'); diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 881c95907b..8328b9ee7a 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1410,7 +1410,8 @@ function phpbb_gen_download_links($param_key, $param_val, $phpbb_root_path, $php foreach ($methods as $method) { - $type = array_pop(explode('.', $method)); + $exploded = explode('.', $method); + $type = array_pop($exploded); $params = array('archive' => $method); $params[$param_key] = $param_val; From 552233d8fd27ca09fbed555582a9880771205929 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 01:03:38 +0200 Subject: [PATCH 540/666] [ticket/11100] Mark can_use_ssl() and can_use_tls() as static. PHPBB3-11100 --- phpBB/includes/functions_jabber.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index d76309d5bb..3d8e403f4b 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -68,7 +68,7 @@ class jabber } $this->password = $password; - $this->use_ssl = ($use_ssl && $this->can_use_ssl()) ? true : false; + $this->use_ssl = ($use_ssl && self::can_use_ssl()) ? true : false; // Change port if we use SSL if ($this->port == 5222 && $this->use_ssl) @@ -83,7 +83,7 @@ class jabber /** * Able to use the SSL functionality? */ - function can_use_ssl() + static public function can_use_ssl() { // Will not work with PHP >= 5.2.1 or < 5.2.3RC2 until timeout problem with ssl hasn't been fixed (http://bugs.php.net/41236) return ((version_compare(PHP_VERSION, '5.2.1', '<') || version_compare(PHP_VERSION, '5.2.3RC2', '>=')) && @extension_loaded('openssl')) ? true : false; @@ -92,7 +92,7 @@ class jabber /** * Able to use TLS? */ - function can_use_tls() + static public function can_use_tls() { if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking') || !function_exists('stream_get_wrappers')) { @@ -442,7 +442,7 @@ class jabber } // Let's use TLS if SSL is not enabled and we can actually use it - if (!$this->session['ssl'] && $this->can_use_tls() && $this->can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls'])) + if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls'])) { $this->add_to_log('Switching to TLS.'); $this->send("\n"); From 06c3868c27c394747bbaa5a8dac6ed83b5d61951 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 13:40:28 +0200 Subject: [PATCH 541/666] [ticket/8713] Adjust test method name to other recursive_set_var() tests. PHPBB3-8713 --- tests/request/type_cast_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index f7e5cd873e..94b6e9146f 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -49,7 +49,7 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $this->assertEquals($expected, $data); } - public function test_untrimmed_strings() + public function test_nested_untrimmed_recursive_set_var() { $data = array(' eviL<3 '); $expected = array(' eviL<3 '); From 2c41b9062a6a8335aa1bfa7c80077f4ae33d33e4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 13:41:51 +0200 Subject: [PATCH 542/666] [ticket/8713] Use correct parameter for nested data. PHPBB3-8713 --- tests/request/type_cast_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index 94b6e9146f..176638dc44 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -54,7 +54,7 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $data = array(' eviL<3 '); $expected = array(' eviL<3 '); - $this->type_cast_helper->recursive_set_var($data, '', true, false); + $this->type_cast_helper->recursive_set_var($data, array(0 => ''), true, false); $this->assertEquals($expected, $data); } From 4550fff55a10be737b76275ae5323675ab1c3939 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 13:43:14 +0200 Subject: [PATCH 543/666] [ticket/8713] Use \t in double quotes instead of tabs. PHPBB3-8713 --- tests/request/type_cast_helper_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index 176638dc44..8203703639 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -51,8 +51,8 @@ class phpbb_type_cast_helper_test extends phpbb_test_case public function test_nested_untrimmed_recursive_set_var() { - $data = array(' eviL<3 '); - $expected = array(' eviL<3 '); + $data = array(" eviL<3\t\t"); + $expected = array(" eviL<3\t\t"); $this->type_cast_helper->recursive_set_var($data, array(0 => ''), true, false); From 160c49351b5ce7d2d811a388a4630ec37258bb8f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 13:44:50 +0200 Subject: [PATCH 544/666] [ticket/8713] Add simple (non-nested) test case for untrimmed set_var(). PHPBB3-8713 --- tests/request/type_cast_helper_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index 8203703639..f41db005af 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -49,6 +49,16 @@ class phpbb_type_cast_helper_test extends phpbb_test_case $this->assertEquals($expected, $data); } + public function test_simple_untrimmed_recursive_set_var() + { + $data = " eviL<3\t\t"; + $expected = " eviL<3\t\t"; + + $this->type_cast_helper->recursive_set_var($data, '', true, false); + + $this->assertEquals($expected, $data); + } + public function test_nested_untrimmed_recursive_set_var() { $data = array(" eviL<3\t\t"); From 798033075ba0bbef8f43c542ca05aae776747917 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:07:06 +0200 Subject: [PATCH 545/666] [ticket/8713] Always trim array keys. PHPBB3-8713 --- phpBB/includes/request/type_cast_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/request/type_cast_helper.php b/phpBB/includes/request/type_cast_helper.php index d3b94aac5a..3039647bfa 100644 --- a/phpBB/includes/request/type_cast_helper.php +++ b/phpBB/includes/request/type_cast_helper.php @@ -184,7 +184,7 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i foreach ($_var as $k => $v) { - $this->set_var($k, $k, $key_type, $multibyte, $trim); + $this->set_var($k, $k, $key_type, $multibyte); $this->recursive_set_var($v, $default_value, $multibyte, $trim); $var[$k] = $v; From c3e0d1b6d12f07df88e31ffd896b275e65b788eb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:07:42 +0200 Subject: [PATCH 546/666] [ticket/8713] Fix type_cast_helper.php doc blocks: Add punctuation etc. PHPBB3-8713 --- phpBB/includes/request/type_cast_helper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/request/type_cast_helper.php b/phpBB/includes/request/type_cast_helper.php index 3039647bfa..1a5274ed14 100644 --- a/phpBB/includes/request/type_cast_helper.php +++ b/phpBB/includes/request/type_cast_helper.php @@ -93,8 +93,8 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i * @param mixed $type The variable type. Will be used with {@link settype()} * @param bool $multibyte Indicates whether string values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks. - * @param bool $trim Indicates whether string values will be be parsed with trim() - * Default is true + * @param bool $trim Indicates whether trim() should be applied to string values. + * Default is true. */ public function set_var(&$result, $var, $type, $multibyte = false, $trim = true) { @@ -149,8 +149,8 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i * @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters. * Default is false, causing all bytes outside the ASCII range (0-127) to * be replaced with question marks. - * @param bool $trim Indicates whether string values will be be parsed with trim() - * Default is true + * @param bool $trim Indicates whether trim() should be applied to string values. + * Default is true. */ public function recursive_set_var(&$var, $default, $multibyte, $trim = true) { From b62c37c5799d4b9e018358c38a731d6664acadf1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:09:12 +0200 Subject: [PATCH 547/666] [ticket/8713] DRY: variable() and untrimed_variable() into a protected method. PHPBB3-8713 --- phpBB/includes/request/request.php | 144 +++++++++++++---------------- 1 file changed, 64 insertions(+), 80 deletions(-) diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index 747ca09624..c6b6610af5 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -200,46 +200,7 @@ class phpbb_request implements phpbb_request_interface */ public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST) { - $path = false; - - // deep direct access to multi dimensional arrays - if (is_array($var_name)) - { - $path = $var_name; - // make sure at least the variable name is specified - if (empty($path)) - { - return (is_array($default)) ? array() : $default; - } - // the variable name is the first element on the path - $var_name = array_shift($path); - } - - if (!isset($this->input[$super_global][$var_name])) - { - return (is_array($default)) ? array() : $default; - } - $var = $this->input[$super_global][$var_name]; - - if ($path) - { - // walk through the array structure and find the element we are looking for - foreach ($path as $key) - { - if (is_array($var) && isset($var[$key])) - { - $var = $var[$key]; - } - else - { - return (is_array($default)) ? array() : $default; - } - } - } - - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte); - - return $var; + return $this->_variable($var_name, $default, $multibyte, $super_global, true); } /** @@ -263,46 +224,7 @@ class phpbb_request implements phpbb_request_interface */ public function untrimed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST) { - $path = false; - - // deep direct access to multi dimensional arrays - if (is_array($var_name)) - { - $path = $var_name; - // make sure at least the variable name is specified - if (empty($path)) - { - return (is_array($default)) ? array() : $default; - } - // the variable name is the first element on the path - $var_name = array_shift($path); - } - - if (!isset($this->input[$super_global][$var_name])) - { - return (is_array($default)) ? array() : $default; - } - $var = $this->input[$super_global][$var_name]; - - if ($path) - { - // walk through the array structure and find the element we are looking for - foreach ($path as $key) - { - if (is_array($var) && isset($var[$key])) - { - $var = $var[$key]; - } - else - { - return (is_array($default)) ? array() : $default; - } - } - } - - $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, false); - - return $var; + return $this->_variable($var_name, $default, $multibyte, $super_global, false); } /** @@ -414,4 +336,66 @@ class phpbb_request implements phpbb_request_interface return array_keys($this->input[$super_global]); } + + /** + * Helper function used by variable() and untrimed_variable(). + * + * @param string|array $var_name The form variable's name from which data shall be retrieved. + * If the value is an array this may be an array of indizes which will give + * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a") + * then specifying array("var", 1) as the name will return "a". + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies which super global should be used + * @param bool $trim Indicates whether trim() should be applied to string values. + * + * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the + * the same as that of $default. If the variable is not set $default is returned. + */ + protected function _variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST, $trim = true) + { + $path = false; + + // deep direct access to multi dimensional arrays + if (is_array($var_name)) + { + $path = $var_name; + // make sure at least the variable name is specified + if (empty($path)) + { + return (is_array($default)) ? array() : $default; + } + // the variable name is the first element on the path + $var_name = array_shift($path); + } + + if (!isset($this->input[$super_global][$var_name])) + { + return (is_array($default)) ? array() : $default; + } + $var = $this->input[$super_global][$var_name]; + + if ($path) + { + // walk through the array structure and find the element we are looking for + foreach ($path as $key) + { + if (is_array($var) && isset($var[$key])) + { + $var = $var[$key]; + } + else + { + return (is_array($default)) ? array() : $default; + } + } + } + + $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, $trim); + + return $var; + } } From f2607fc9e80c6f9ad7543b7be5ea6f294aa6c40a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:15:56 +0200 Subject: [PATCH 548/666] [ticket/8713] Rename untrimed_variable() to untrimmed_variable(). PHPBB3-8713 --- phpBB/includes/acp/acp_language.php | 6 +++--- phpBB/includes/acp/acp_users.php | 4 ++-- phpBB/includes/functions.php | 4 ++-- phpBB/includes/request/request.php | 4 ++-- phpBB/includes/ucp/ucp_profile.php | 6 +++--- phpBB/includes/ucp/ucp_register.php | 4 ++-- phpBB/install/install_update.php | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 87cf605d8e..b5f5ba2312 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -100,11 +100,11 @@ class acp_language switch ($method) { case 'ftp': - $transfer = new ftp(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; case 'ftp_fsock': - $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); break; default: @@ -404,7 +404,7 @@ class acp_language trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR); } - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); if (($result = $transfer->open_session()) !== true) { diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b9958ed0f1..2905b84d57 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -770,8 +770,8 @@ class acp_users 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)), 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), 'email' => strtolower(request_var('user_email', $user_row['user_email'])), - 'new_password' => $request->untrimed_variable('new_password', '', true), - 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), + 'new_password' => $request->untrimmed_variable('new_password', '', true), + 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), ); // Validation data - we do not check the password complexity setting here diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1cdda60855..a2f8a57938 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3044,11 +3044,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa trigger_error('NO_AUTH_ADMIN'); } - $password = $request->untrimed_variable('password_' . $credential, '', true); + $password = $request->untrimmed_variable('password_' . $credential, '', true); } else { - $password = $request->untrimed_variable('password', '', true); + $password = $request->untrimmed_variable('password', '', true); } $username = request_var('username', '', true); diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index c6b6610af5..aa62c3b610 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -222,7 +222,7 @@ class phpbb_request implements phpbb_request_interface * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the * the same as that of $default. If the variable is not set $default is returned. */ - public function untrimed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST) + public function untrimmed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST) { return $this->_variable($var_name, $default, $multibyte, $super_global, false); } @@ -338,7 +338,7 @@ class phpbb_request implements phpbb_request_interface } /** - * Helper function used by variable() and untrimed_variable(). + * Helper function used by variable() and untrimmed_variable(). * * @param string|array $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 68d5dd5d65..db1e3e4722 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -46,9 +46,9 @@ class ucp_profile $data = array( 'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)), 'email' => strtolower(request_var('email', $user->data['user_email'])), - 'new_password' => $request->untrimed_variable('new_password', '', true), - 'cur_password' => $request->untrimed_variable('cur_password', '', true), - 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), + 'new_password' => $request->untrimmed_variable('new_password', '', true), + 'cur_password' => $request->untrimmed_variable('cur_password', '', true), + 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), ); add_form_key('ucp_reg_details'); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 6fab189a99..5ae92a5cea 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -170,8 +170,8 @@ class ucp_register $data = array( 'username' => utf8_normalize_nfc(request_var('username', '', true)), - 'new_password' => $request->untrimed_variable('new_password', '', true), - 'password_confirm' => $request->untrimed_variable('password_confirm', '', true), + 'new_password' => $request->untrimmed_variable('new_password', '', true), + 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', $timezone), diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 4b5a23e497..1ecedecce6 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,7 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +948,7 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); $transfer->open_session(); } From d543f0ffb1334d0a22c30077a9ed27c098dc4af5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 8 Sep 2012 14:41:41 +0200 Subject: [PATCH 549/666] [ticket/11101] Delay execution of container processors Also fix the name of the ext processor service. PHPBB3-11101 --- phpBB/common.php | 14 +++++++------- phpBB/config/services.yml | 2 +- phpBB/download/file.php | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 281eb88c4d..c6bb5c6cfe 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,13 +100,6 @@ $processor->process($phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // set up caching $cache = $phpbb_container->get('cache'); @@ -132,6 +125,13 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display'))); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 133a43b77e..c3d2494952 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -89,7 +89,7 @@ services: - .%core.php_ext% - @cache.driver - processor.config: + processor.ext: class: phpbb_di_processor_ext arguments: - @ext.manager diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 8766c6d030..7ed53d54b6 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -61,13 +61,6 @@ if (isset($_GET['avatar'])) $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); - $ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); - foreach ($ids as $id) - { - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); - } - // set up caching $cache = $phpbb_container->get('cache'); @@ -92,6 +85,13 @@ if (isset($_GET['avatar'])) $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); + $ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); + foreach ($ids as $id) + { + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); + } + // worst-case default $browser = strtolower($request->header('User-Agent', 'msie 6.0')); From cc0c378caf9bfc480391a9d11d5a4d78c0df097c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 14:40:35 +0200 Subject: [PATCH 550/666] [ticket/8713] Call htmlspecialchars_decode() on transfer (e.g. ftp) passwords. PHPBB3-8713 --- phpBB/includes/acp/acp_language.php | 27 ++++++++++++++++++++++++--- phpBB/install/install_update.php | 18 ++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index b5f5ba2312..2be1ccfc41 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -100,11 +100,25 @@ class acp_language switch ($method) { case 'ftp': - $transfer = new ftp(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); break; case 'ftp_fsock': - $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new ftp_fsock( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); break; default: @@ -404,7 +418,14 @@ class acp_language trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR); } - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); if (($result = $transfer->open_session()) !== true) { diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 1ecedecce6..8c044550f3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -862,7 +862,14 @@ class install_update extends module $test_connection = false; if ($test_ftp_connection || $submit) { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); $test_connection = $transfer->open_session(); // Make sure that the directory is correct by checking for the existence of common.php @@ -948,7 +955,14 @@ class install_update extends module } else { - $transfer = new $method(request_var('host', ''), request_var('username', ''), $request->untrimmed_variable('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', '')); + $transfer = new $method( + request_var('host', ''), + request_var('username', ''), + htmlspecialchars_decode($request->untrimmed_variable('password', '')), + request_var('root_path', ''), + request_var('port', ''), + request_var('timeout', '') + ); $transfer->open_session(); } From 1e05fd4c627d23b7756796c5acac27d2562a8607 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 15:01:29 +0200 Subject: [PATCH 551/666] [ticket/8713] Trim password in auth_db to keep compatibility. PHPBB3-8713 --- phpBB/includes/auth/auth_db.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index 76790e4dad..ac944532a5 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -41,6 +41,10 @@ function login_db($username, $password, $ip = '', $browser = '', $forwarded_for global $db, $config; global $request; + // Auth plugins get the password untrimmed. + // For compatibility we trim() here. + $password = trim($password); + // do not allow empty password if (!$password) { From 73a75fc3d387f8d923186c5c04b1ca7bc6cda4ef Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 8 Sep 2012 15:02:06 +0200 Subject: [PATCH 552/666] [ticket/8713] Revert changes to ucp_profile, ucp_register and acp_users. Currently only auth_db is supported there and the password needs to be trimmed for compatibility because user_password stores phpbb_hash(htmlspecialchars(trim($password))) Setting passwords for other auth modules is currently not supported. Once setting/changing passwords is supported by auth plugins, the untrimmed_variable() should be used here and the result should be passed to the auth plugin. PHPBB3-8713 --- phpBB/includes/acp/acp_users.php | 4 ++-- phpBB/includes/ucp/ucp_profile.php | 6 +++--- phpBB/includes/ucp/ucp_register.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 2905b84d57..985a12d9ce 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -770,8 +770,8 @@ class acp_users 'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)), 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0), 'email' => strtolower(request_var('user_email', $user_row['user_email'])), - 'new_password' => $request->untrimmed_variable('new_password', '', true), - 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), + 'new_password' => $request->variable('new_password', '', true), + 'password_confirm' => $request->variable('password_confirm', '', true), ); // Validation data - we do not check the password complexity setting here diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index db1e3e4722..89bf20a30f 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -46,9 +46,9 @@ class ucp_profile $data = array( 'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)), 'email' => strtolower(request_var('email', $user->data['user_email'])), - 'new_password' => $request->untrimmed_variable('new_password', '', true), - 'cur_password' => $request->untrimmed_variable('cur_password', '', true), - 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), + 'new_password' => $request->variable('new_password', '', true), + 'cur_password' => $request->variable('cur_password', '', true), + 'password_confirm' => $request->variable('password_confirm', '', true), ); add_form_key('ucp_reg_details'); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 5ae92a5cea..c57aec00a0 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -170,8 +170,8 @@ class ucp_register $data = array( 'username' => utf8_normalize_nfc(request_var('username', '', true)), - 'new_password' => $request->untrimmed_variable('new_password', '', true), - 'password_confirm' => $request->untrimmed_variable('password_confirm', '', true), + 'new_password' => $request->variable('new_password', '', true), + 'password_confirm' => $request->variable('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', $timezone), From 238fab3bb908013fb0d7c95278b0a2a3b7fa5bae Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 9 Sep 2012 21:41:29 +0200 Subject: [PATCH 553/666] [ticket/8713] Update untrimmed_variable() doc block. PHPBB3-8713 --- phpBB/includes/request/request.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php index aa62c3b610..a06fc0d85d 100644 --- a/phpBB/includes/request/request.php +++ b/phpBB/includes/request/request.php @@ -204,9 +204,9 @@ class phpbb_request implements phpbb_request_interface } /** - * Get a variable, but without trimming strings - * Same functionality as variable(), except does not run trim() on strings - * All variables in GET or POST requests should be retrieved through this function to maximise security. + * Get a variable, but without trimming strings. + * Same functionality as variable(), except does not run trim() on strings. + * This method should be used when handling passwords. * * @param string|array $var_name The form variable's name from which data shall be retrieved. * If the value is an array this may be an array of indizes which will give From ce7cffcf9ebb21bccf1fae4da41a924708429e94 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 11 Sep 2012 09:42:29 +0100 Subject: [PATCH 554/666] [ticket/11045] Removed file conflict tests for compress class PHPBB3-11045 --- tests/compress/compress_test.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php index ac8dd358d3..65094671e3 100644 --- a/tests/compress/compress_test.php +++ b/tests/compress/compress_test.php @@ -25,12 +25,6 @@ class phpbb_compress_test extends phpbb_test_case 'dir/subdir/4.txt', ); - protected $conflicts = array( - '1_1.txt', - '1_2.txt', - 'dir/2_1.txt', - ); - protected function setUp() { // Required for compress::add_file @@ -88,11 +82,6 @@ class phpbb_compress_test extends phpbb_test_case ); $compress->add_custom_file($this->path . 'dir/3.txt', 'dir/3.txt'); $compress->add_data(file_get_contents($this->path . 'dir/subdir/4.txt'), 'dir/subdir/4.txt'); - - // Add multiples of the same file to check conflicts are handled - $compress->add_file($this->path . '1.txt', $this->path); - $compress->add_file($this->path . '1.txt', $this->path); - $compress->add_file($this->path . 'dir/2.txt', $this->path); } protected function valid_extraction($extra = array()) @@ -152,7 +141,7 @@ class phpbb_compress_test extends phpbb_test_case $compress->mode = 'r'; $compress->open(); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction($this->conflicts); + $this->valid_extraction(); } /** @@ -168,6 +157,6 @@ class phpbb_compress_test extends phpbb_test_case $compress = new compress_zip('r', $zip); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction($this->conflicts); + $this->valid_extraction(); } } From 503989979a2e6a7fb9d64ed249b09a0bef2b2f95 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 13 Sep 2012 16:44:26 -0400 Subject: [PATCH 555/666] [ticket/11086] Fix database_update.php to use Dependency Injection Container PHPBB3-11086 --- phpBB/install/database_update.php | 45 ++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0b470ced26..323ba0c876 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -7,6 +7,10 @@ * */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + define('UPDATES_TO_VERSION', '3.1.0-dev'); // Enter any version to update from to test updates. The version within the db will not be updated. @@ -107,21 +111,38 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); -$phpbb_class_loader->register(); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); +$loader->load('services.yml'); + +// We must include the DI processor class files because the class loader +// is not yet set up +require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); + +$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); +$processor->process($phpbb_container); + +// Setup class loader first +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); + +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} // set up caching -$cache_factory = new phpbb_cache_factory($acm_type); -$cache = $cache_factory->get_service(); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); +$cache = $phpbb_container->get('cache'); -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); -$user = new phpbb_user(); -$db = new $sql_db(); +// Instantiate some basic classes +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function From 298fa894e7ea0807a295cd0ed55cabef8a27a3f3 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 13 Sep 2012 16:56:09 -0400 Subject: [PATCH 556/666] [ticket/11086] Move DI processing below $request definition As per PR #991 (ticket/11101). PHPBB3-11086 --- phpBB/install/database_update.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 323ba0c876..5fa6166913 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -119,7 +119,6 @@ $loader->load('services.yml'); // is not yet set up require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); - $processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); $processor->process($phpbb_container); @@ -127,13 +126,6 @@ $processor->process($phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // set up caching $cache = $phpbb_container->get('cache'); @@ -144,6 +136,13 @@ $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function From b24ee89cfc22fad322dcfc577d1c7d50bbd57809 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 11 Sep 2012 09:44:13 +0100 Subject: [PATCH 557/666] [ticket/11109] Re-add file conflict checks to compress class PHPBB3-11109 --- tests/compress/compress_test.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php index 65094671e3..ac8dd358d3 100644 --- a/tests/compress/compress_test.php +++ b/tests/compress/compress_test.php @@ -25,6 +25,12 @@ class phpbb_compress_test extends phpbb_test_case 'dir/subdir/4.txt', ); + protected $conflicts = array( + '1_1.txt', + '1_2.txt', + 'dir/2_1.txt', + ); + protected function setUp() { // Required for compress::add_file @@ -82,6 +88,11 @@ class phpbb_compress_test extends phpbb_test_case ); $compress->add_custom_file($this->path . 'dir/3.txt', 'dir/3.txt'); $compress->add_data(file_get_contents($this->path . 'dir/subdir/4.txt'), 'dir/subdir/4.txt'); + + // Add multiples of the same file to check conflicts are handled + $compress->add_file($this->path . '1.txt', $this->path); + $compress->add_file($this->path . '1.txt', $this->path); + $compress->add_file($this->path . 'dir/2.txt', $this->path); } protected function valid_extraction($extra = array()) @@ -141,7 +152,7 @@ class phpbb_compress_test extends phpbb_test_case $compress->mode = 'r'; $compress->open(); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction(); + $this->valid_extraction($this->conflicts); } /** @@ -157,6 +168,6 @@ class phpbb_compress_test extends phpbb_test_case $compress = new compress_zip('r', $zip); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction(); + $this->valid_extraction($this->conflicts); } } From 0c56bd45eff15b0bff2672ed08b390d0248625d8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 13:15:08 -0500 Subject: [PATCH 558/666] [ticket/11021] Better language strings for site home url/text Correct the logo title to be {L_HOME} if {U_HOME} is used. Check if the Home text is instead of just equal to false when outputting it to the template PHPBB3-11021 --- phpBB/includes/functions.php | 2 +- phpBB/language/en/acp/board.php | 10 +++++----- phpBB/styles/prosilver/template/overall_header.html | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a8d3c25052..91e2b1b794 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4935,7 +4935,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], - 'L_HOME' => ($config['site_home_text']) ? $config['site_home_text'] : $user->lang['HOME'], + 'L_HOME' => (!empty($config['site_home_text'])) ? $config['site_home_text'] : $user->lang['HOME'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 6b043b887d..b80aec1f4a 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -45,14 +45,14 @@ $lang = array_merge($lang, array( 'DISABLE_BOARD' => 'Disable board', 'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users. You can also enter a short (255 character) message to display if you wish.', 'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list', - 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', + 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.', 'OVERRIDE_STYLE' => 'Override user style', 'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s style with the default.', 'SITE_DESC' => 'Site description', - 'SITE_HOME_TEXT' => 'Site home text', - 'SITE_HOME_TEXT_EXPLAIN' => 'Specify a Site Home Text to use your own instead of the default text in the breadcrumbs ’Home.’', - 'SITE_HOME_URL' => 'Site home URL', - 'SITE_HOME_URL_EXPLAIN' => 'If you specify a Site Home URL, a link to this page will be added to your board’s breadcrumbs and the site logo will also be linked to this address.', + 'SITE_HOME_TEXT' => 'Main website text', + 'SITE_HOME_TEXT_EXPLAIN' => 'This text will be displayed as a link to your website homepage in the board’s breadcrumbs. If not specified, it will default to ’Home’.', + 'SITE_HOME_URL' => 'Main website URL', + 'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs. The board logo will also link to this URL.', 'SITE_NAME' => 'Site name', 'SYSTEM_TIMEZONE' => 'Guest timezone', 'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.', diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 13907a6ae4..47a53c8f60 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -95,7 +95,7 @@
- +

{SITENAME}

{SITE_DESCRIPTION}

From 7a4701399412faedd725195f849c18c770a126cb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Sep 2012 10:44:18 -0500 Subject: [PATCH 559/666] [ticket/11021] Use L_SITE_HOME instead of L_HOME Check site home url against !== '', not empty PHPBB3-11021 --- phpBB/includes/functions.php | 2 +- phpBB/styles/prosilver/template/overall_footer.html | 4 ++-- phpBB/styles/prosilver/template/overall_header.html | 4 ++-- phpBB/styles/subsilver2/template/breadcrumbs.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 91e2b1b794..0aa3aa016e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4935,7 +4935,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_INDEX' => $user->lang['FORUM_INDEX'], - 'L_HOME' => (!empty($config['site_home_text'])) ? $config['site_home_text'] : $user->lang['HOME'], + 'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'], 'L_ONLINE_EXPLAIN' => $l_online_time, 'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'), diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index ed05bbe80f..30912b6637 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -4,9 +4,9 @@ diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 7d6fed6164..960cc5b335 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -33,7 +33,7 @@ $convertor_data = array( 'forum_name' => 'phpBB 2.0.x', 'version' => '1.0.3', 'phpbb_version' => '3.0.11', - 'author' => 'phpBB Group', + 'author' => 'phpBB Group', 'dbms' => $dbms, 'dbhost' => $dbhost, 'dbport' => $dbport, diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5a186d0eeb..40837145ba 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -527,7 +527,7 @@ function _print_footer()
diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 5135e2dbd8..ad46e273c2 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -569,7 +569,7 @@ class module echo '
'; echo '
'; echo ' '; echo ''; echo ''; diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html index d92abb06dd..67e14defc3 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html @@ -48,7 +48,7 @@ diff --git a/phpBB/styles/prosilver/template/viewtopic_print.html b/phpBB/styles/prosilver/template/viewtopic_print.html index 0fd0e6dfa6..39d2d76394 100644 --- a/phpBB/styles/prosilver/template/viewtopic_print.html +++ b/phpBB/styles/prosilver/template/viewtopic_print.html @@ -44,7 +44,7 @@ diff --git a/phpBB/styles/prosilver/theme/stylesheet.css b/phpBB/styles/prosilver/theme/stylesheet.css index 4a7356fbaa..40620179a1 100644 --- a/phpBB/styles/prosilver/theme/stylesheet.css +++ b/phpBB/styles/prosilver/theme/stylesheet.css @@ -3,7 +3,7 @@ Style name: prosilver (the default phpBB 3.0.x style) Based on style: Original author: Tom Beddard ( http://www.subblue.com/ ) - Modified by: phpBB Group ( http://www.phpbb.com/ ) + Modified by: phpBB Group ( https://www.phpbb.com/ ) -------------------------------------------------------------- */ diff --git a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html index 24194e4c26..cd55c16a50 100644 --- a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html +++ b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html @@ -114,7 +114,7 @@ hr.sep { {S_TIMEZONE} - Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/
+ Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/
diff --git a/phpBB/styles/subsilver2/template/viewtopic_print.html b/phpBB/styles/subsilver2/template/viewtopic_print.html index 964c95f677..1ca1eccc99 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_print.html +++ b/phpBB/styles/subsilver2/template/viewtopic_print.html @@ -128,7 +128,7 @@ hr.sep { {S_TIMEZONE} - Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/
+ Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/
diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index 444104ae3c..177a988e93 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -3,7 +3,7 @@ Style name: subsilver2 Based on style: subSilver (the default phpBB 2.0.x style) Original author: Tom Beddard ( http://www.subblue.com/ ) - Modified by: phpBB Group ( http://www.phpbb.com/ ) + Modified by: phpBB Group ( https://www.phpbb.com/ ) -------------------------------------------------------------- */ From 305abfde963e764d5e6be0c7b1c1b9496a2477b2 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 8 Oct 2012 10:58:04 +0530 Subject: [PATCH 570/666] [ticket/11051] fix spaces PHPBB3-11051 --- phpBB/includes/search/fulltext_native.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 1100484ebd..bbc2236b3c 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -23,9 +23,9 @@ if (!defined('IN_PHPBB')) class phpbb_search_fulltext_native extends phpbb_search_base { protected $stats = array(); - protected $word_length = array(); - protected $search_query; - protected $common_words = array(); + protected $word_length = array(); + protected $search_query; + protected $common_words = array(); protected $must_contain_ids = array(); protected $must_not_contain_ids = array(); From 5db30e66fd03dacb4bb961afd9672eb9d65ba148 Mon Sep 17 00:00:00 2001 From: Vinny Date: Tue, 9 Oct 2012 00:31:59 -0300 Subject: [PATCH 571/666] [ticket/11139] Fix fatal error on colour swatch window PHPBB3-11139 --- phpBB/adm/swatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 434b00e542..5e8984db70 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_template($phpbb_root_path . 'adm/style', 'admin'); +$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_filenames(array( 'body' => 'colour_swatch.html') From cf810fb775407d6e6e5aa62a072b141bdb61e3c9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 9 Oct 2012 22:00:28 -0500 Subject: [PATCH 572/666] [ticket/11140] Fix an error from an incorrect variable name PHPBB3-11140 --- phpBB/includes/mcp/mcp_front.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 13398e62bc..ba4b15895a 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -251,7 +251,7 @@ function mcp_front_view($id, $mode, $action) 'ORDER_BY' => 'p.message_time DESC', ); - $sql_ary = $db->sql_build_query('SELECT', $sql_ary); + $sql = $db->sql_build_query('SELECT', $sql_ary); $result = $db->sql_query_limit($sql, 5); $pm_by_id = $pm_list = array(); From d434672dde1592f51013459357c25ed49887d12f Mon Sep 17 00:00:00 2001 From: Senky Date: Mon, 23 Jul 2012 14:28:47 +0200 Subject: [PATCH 573/666] [ticket/10967] adding $root_path to posting_get_topic_icons PHPBB3-10967 --- phpBB/includes/functions_posting.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 68b6199cf5..aa15593a19 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -288,13 +288,15 @@ function posting_gen_topic_icons($mode, $icon_id) if (sizeof($icons)) { + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + foreach ($icons as $id => $data) { if ($data['display']) { $template->assign_block_vars('topic_icon', array( 'ICON_ID' => $id, - 'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'], + 'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'], 'ICON_WIDTH' => $data['width'], 'ICON_HEIGHT' => $data['height'], @@ -2637,7 +2639,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * - 'topic_last_post_subject' * - 'topic_last_poster_name' * - 'topic_last_poster_colour' -* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time(). +* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time(). * @return string An URL to the bumped topic, example: ./viewtopic.php?forum_id=1&topic_id=2&p=3#p3 */ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) From 571d352eed670ad986bd653a2ac0bd81429c9cf5 Mon Sep 17 00:00:00 2001 From: Vinny Date: Tue, 9 Oct 2012 14:29:26 -0300 Subject: [PATCH 574/666] [ticket/11139] Adding the $phpbb_admin_path variable PHPBB3-11139 --- phpBB/adm/swatch.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 5e8984db70..86498a255f 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -21,6 +21,8 @@ $user->session_begin(false); $auth->acl($user->data); $user->setup(); +$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './'; + // Set custom template for admin area $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', ''); From d376348acf271ab0e2bcba4e8eb5993192d0ef87 Mon Sep 17 00:00:00 2001 From: westr Date: Tue, 16 Oct 2012 12:44:33 +0100 Subject: [PATCH 575/666] [ticket/11093] acp_users_overview.html has a wrongly placed Amended the closing dd tag to the appropriate line: line 145 instead of 141 PHPBB3-11093 --- phpBB/adm/style/acp_users_overview.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_users_overview.html b/phpBB/adm/style/acp_users_overview.html index e2dcdb6307..ba350a13fb 100644 --- a/phpBB/adm/style/acp_users_overview.html +++ b/phpBB/adm/style/acp_users_overview.html @@ -142,10 +142,11 @@

{L_DELETE_USER_EXPLAIN}
-
+ {L_USER_NO_POSTS_TO_DELETE} +

From c630480ca1a426cb0897be35626baac2694fccf5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 17 Oct 2012 15:03:06 -0400 Subject: [PATCH 576/666] [ticket/10848] Redirect from adm to installer correctly. PHPBB3-10848 --- phpBB/common.php | 6 +++- phpBB/includes/functions.php | 30 ++++++++++++++++++++ tests/functions/clean_path_test.php | 44 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/functions/clean_path_test.php diff --git a/phpBB/common.php b/phpBB/common.php index 491addc5e0..bdb33707cc 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -38,10 +38,14 @@ if (!defined('PHPBB_INSTALLED')) $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); } + // $phpbb_root_path accounts for redirects from e.g. /adm + $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/index.' . $phpEx; // Replace any number of consecutive backslashes and/or slashes with a single slash // (could happen on some proxy setups and/or Windows servers) - $script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx; $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); + // Eliminate . and .. from the path + require($phpbb_root_path . 'includes/functions.' . $phpEx); + $script_path = clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ca58220619..2391b45038 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1176,6 +1176,36 @@ else } } +/** +* Eliminates useless . and .. components from specified path. +* +* @param string $path Path to clean +* @return string Cleaned path +*/ +function clean_path($path) +{ + $exploded = explode('/', $path); + $filtered = array(); + foreach ($exploded as $part) + { + if ($part === '.' && !empty($filtered)) + { + continue; + } + + if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '..') + { + array_pop($filtered); + } + else + { + $filtered[] = $part; + } + } + $path = implode('/', $filtered); + return $path; +} + if (!function_exists('htmlspecialchars_decode')) { /** diff --git a/tests/functions/clean_path_test.php b/tests/functions/clean_path_test.php new file mode 100644 index 0000000000..4c8fe54909 --- /dev/null +++ b/tests/functions/clean_path_test.php @@ -0,0 +1,44 @@ +assertEquals($expected, $output); + } +} From bb09cd9c8e76ac3af848d09db8ea1928dab66158 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 17 Oct 2012 15:13:35 -0400 Subject: [PATCH 577/666] [ticket/10848] Add phpbb_ prefix. PHPBB3-10848 --- phpBB/common.php | 2 +- phpBB/includes/functions.php | 2 +- tests/functions/clean_path_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index bdb33707cc..5849d48453 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -45,7 +45,7 @@ if (!defined('PHPBB_INSTALLED')) $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); // Eliminate . and .. from the path require($phpbb_root_path . 'includes/functions.' . $phpEx); - $script_path = clean_path($script_path); + $script_path = phpbb_clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2391b45038..65d8be32ad 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1182,7 +1182,7 @@ else * @param string $path Path to clean * @return string Cleaned path */ -function clean_path($path) +function phpbb_clean_path($path) { $exploded = explode('/', $path); $filtered = array(); diff --git a/tests/functions/clean_path_test.php b/tests/functions/clean_path_test.php index 4c8fe54909..bcbe9838d9 100644 --- a/tests/functions/clean_path_test.php +++ b/tests/functions/clean_path_test.php @@ -37,7 +37,7 @@ class phpbb_clean_path_test extends phpbb_test_case */ public function test_clean_path($input, $expected) { - $output = clean_path($input); + $output = phpbb_clean_path($input); $this->assertEquals($expected, $output); } From e76fd6a3959c632a2e012ce82568b9e04f87b8db Mon Sep 17 00:00:00 2001 From: Drae Date: Sun, 22 Jul 2012 16:24:07 +0100 Subject: [PATCH 578/666] [ticket/11018] Attempt to fix li.pagination alignment issue This is somewhat kludgy fix for the vertical alignment issue for pagination contained within a linklist parented li element. Tested and doesn't seem to impact anything else negatively. May need further browser testing. PHPBB3-11018 --- phpBB/styles/prosilver/theme/common.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 4b4fa263b1..ff46163f71 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -510,9 +510,16 @@ li.pagination { margin-bottom: 0; } +li.pagination ul { + margin-top: -2px; + vertical-align: middle; +} + .pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { display: inline; padding: 0; + font-size: 100%; + line-height: normal; } .pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span { From a51aa9b47c526d173386510f3f67303243be03fc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 13:09:22 +0200 Subject: [PATCH 579/666] [ticket/11018] Fix minor issues with CSS in prosilver PHPBB3-11018 --- phpBB/styles/prosilver/theme/colours.css | 6 +++--- phpBB/styles/prosilver/theme/common.css | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 29968cbb14..d7ce9a7622 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -151,9 +151,9 @@ dl.details dd { border-color: #B4BAC0; } -.pagination li.ellipsis span { +.pagination li.ellipsis span { background-color: transparent; - color: #000 + color: #000000; } .pagination li.active span { @@ -165,7 +165,7 @@ dl.details dd { .pagination li a:hover, .pagination .active a:hover { border-color: #368AD2; background-color: #368AD2; - color: #FFF; + color: #FFFFFF; } .pagination li a:active, .pagination li.active a:active { diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index ff46163f71..50b22f44df 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -515,11 +515,11 @@ li.pagination ul { vertical-align: middle; } -.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { +.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { display: inline; padding: 0; font-size: 100%; - line-height: normal; + line-height: normal; } .pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span { From 43a713ea8356221eb199c5aba066efa15013c186 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 13:11:07 +0200 Subject: [PATCH 580/666] [ticket/11067] Copy prosilver CSS to adm, so the pagination looks the same PHPBB3-11067 PHPBB3-11018 --- phpBB/adm/style/admin.css | 100 +++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 585707600d..8551c952c7 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1148,55 +1148,79 @@ input.disabled { width: auto; text-align: right; margin-top: 5px; - font-size: 0.85em; - padding-bottom: 2px; + float: right; } .rtl .pagination { text-align: left; + float: left; } -.pagination strong, -.pagination b { - font-weight: normal; -} - -.pagination span.page-sep { - display:none; -} - -.pagination span strong { - padding: 0 2px; - margin: 0 2px; - font-weight: normal; - font-size: 0.85em; - color: #FFFFFF; - background: #4692BF; - border: 1px solid #4692BF; -} - -.pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active { - font-weight: normal; - font-size: 0.85em; - text-decoration: none; - color: #5C758C; - margin: 0 2px; - padding: 0 2px; - background: #ECEDEE; - border: 1px solid #B4BAC0; -} - -.pagination span a:hover { - border-color: #368AD2; - background: #368AD2; - color: #FFFFFF; - text-decoration: none; +li.pagination { + margin-top: 0; } .pagination img { vertical-align: middle; } +.pagination ul { + display: inline-block; + *display: inline; /* IE7 inline-block hack */ + *zoom: 1; + margin-left: 0; + margin-bottom: 0; +} + +li.pagination ul { + margin-top: -2px; + vertical-align: middle; +} + +.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li { + display: inline; + padding: 0; + font-size: 100%; + line-height: normal; +} + +.pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span { + font-weight: normal; + text-decoration: none; + padding: 0 2px; + border: 1px solid transparent; + font-size: 0.9em; + line-height: 1.5em; +} + +.pagination li a, .pagination li a:link, .pagination li a:visited { + color: #5C758C; + background-color: #ECEDEE; + border-color: #B4BAC0; +} + +.pagination li.ellipsis span { + background-color: transparent; + color: #000000; +} + +.pagination li.active span { + color: #FFFFFF; + background-color: #4692BF; + border-color: #4692BF; +} + +.pagination li a:hover, .pagination .active a:hover { + color: #FFFFFF; + background-color: #368AD2; + border-color: #368AD2; +} + +.pagination li a:active, .pagination li.active a:active { + color: #5C758C; + background-color: #ECEDEE; + border-color: #B4BAC0; +} /* Action Highlighting ---------------------------------------- */ @@ -1727,4 +1751,4 @@ fieldset.permissions .padding { .requirements_not_met dt label, .requirements_not_met dd p { color: #FFFFFF; font-size: 1.4em; -} \ No newline at end of file +} From fa5753de707e0b24c686cf75a7ae9d261bc2a8f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 13:20:45 +0200 Subject: [PATCH 581/666] [ticket/11018] Swap prev/next links on pagination to the old order In the old pagination Prev was left of the pagination and Next right of the pagination. While moving these blocks, I also removed the whitespaces, which were introduced. PHPBB3-11023 PHPBB3-11018 --- phpBB/includes/functions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0c9421c12f..08dd03504c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2112,14 +2112,14 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; } - if ($on_page != $total_pages) + if ($on_page != 1) { $template->assign_block_vars($block_var_name, array( 'PAGE_NUMBER' => '', - 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page), + 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page), 'S_IS_CURRENT' => false, - 'S_IS_PREV' => false, - 'S_IS_NEXT' => true, + 'S_IS_PREV' => true, + 'S_IS_NEXT' => false, 'S_IS_ELLIPSIS' => false, )); } @@ -2166,14 +2166,14 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam } while ($at_page <= $total_pages); - if ($on_page != 1) + if ($on_page != $total_pages) { $template->assign_block_vars($block_var_name, array( 'PAGE_NUMBER' => '', - 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page), + 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page), 'S_IS_CURRENT' => false, - 'S_IS_PREV' => true, - 'S_IS_NEXT' => false, + 'S_IS_PREV' => false, + 'S_IS_NEXT' => true, 'S_IS_ELLIPSIS' => false, )); } From 5ea662f649833f50483da544b513ca102e390fd8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 14:34:48 +0200 Subject: [PATCH 582/666] [ticket/11014] Restore template vars for next/previous links They were dropped while the function was refactored: If the block_var_name is a nested block, we will use the last (most inner) block as a prefix for the template variables. If the last block name is pagination, the prefix is empty. If the rest of the block_var_name is not empty, we will modify the last row of that block and add our pagination items. PHPBB3-11014 --- phpBB/includes/functions.php | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 08dd03504c..4e5be20dbf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2177,6 +2177,45 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam 'S_IS_ELLIPSIS' => false, )); } + + // If the block_var_name is a nested block, we will use the last (most + // inner) block as a prefix for the template variables. If the last block + // name is pagination, the prefix is empty. If the rest of the + // block_var_name is not empty, we will modify the last row of that block + // and add our pagination items. + $tpl_block_name = $tpl_prefix = ''; + if (strrpos($block_var_name, '.') !== false) + { + $tpl_block_name = substr($block_var_name, 0, strrpos($block_var_name, '.')); + $tpl_prefix = strtoupper(substr($block_var_name, strrpos($block_var_name, '.') + 1)); + } + else + { + $tpl_prefix = strtoupper($block_var_name); + } + $tpl_prefix = ($tpl_prefix == 'PAGINATION') ? '' : $tpl_prefix . '_'; + + $previous_page = ($on_page != 1) ? $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page) : ''; + + $template_array = array( + $tpl_prefix . 'BASE_URL' => $base_url, + 'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url), + $tpl_prefix . 'PER_PAGE' => $per_page, + $tpl_prefix . 'PREVIOUS_PAGE' => $previous_page, + $tpl_prefix . 'PREV_PAGE' => $previous_page, + $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page) : '', + $tpl_prefix . 'TOTAL_PAGES' => $total_pages, + $tpl_prefix . 'CURRENT_PAGE' => $on_page, + ); + + if ($tpl_block_name) + { + $template->alter_block_array($tpl_block_name, $template_array, true, 'change'); + } + else + { + $template->assign_vars($template_array); + } } /** From ada2d4c91bb063f3d9d591bfc3ce9552957772e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 14:35:57 +0200 Subject: [PATCH 583/666] [ticket/11018] Always display previous/next links if we can display one PHPBB3-11018 --- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 4534dc5bcc..01b6a504a2 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -245,7 +245,7 @@ - +

From ceb5a40eecbc60577ce0735254a4a189d719302e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 25 Aug 2012 14:53:21 +0200 Subject: [PATCH 584/666] [ticket/11023] Fix additional whitespaces that were added by PHPBB3-10968 PHPBB3-11023 --- phpBB/includes/acp/acp_attachments.php | 4 ++-- phpBB/includes/acp/acp_groups.php | 4 ++-- phpBB/includes/acp/acp_icons.php | 4 ++-- phpBB/includes/acp/acp_inactive.php | 5 ++--- phpBB/includes/acp/acp_logs.php | 2 +- phpBB/includes/acp/acp_users.php | 4 ++-- phpBB/includes/functions.php | 1 - phpBB/includes/mcp/mcp_forum.php | 2 +- phpBB/includes/mcp/mcp_logs.php | 4 ++-- phpBB/includes/mcp/mcp_notes.php | 2 +- phpBB/includes/mcp/mcp_pm_reports.php | 4 ++-- phpBB/includes/mcp/mcp_queue.php | 2 +- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 2 +- phpBB/includes/mcp/mcp_warn.php | 2 +- phpBB/includes/ucp/ucp_attachments.php | 4 ++-- phpBB/includes/ucp/ucp_pm_viewfolder.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/search.php | 4 ++-- 19 files changed, 27 insertions(+), 29 deletions(-) diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index eccc935a6e..9d6c2d5de1 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1163,7 +1163,7 @@ class acp_attachments $template->assign_vars(array( 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, 'U_ACTION' => $this->u_action,) - ); + ); } // Make sure $start is set to the last page if it exceeds the amount @@ -1224,7 +1224,7 @@ class acp_attachments $base_url = $this->u_action . "&$u_sort_param"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start); - + $template->assign_vars(array( 'TOTAL_FILES' => $num_files, 'TOTAL_SIZE' => get_formatted_filesize($total_size), diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index f88fa76df1..9621407211 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -683,8 +683,8 @@ class acp_groups } $base_url = $this->u_action . "&action=$action&g=$group_id"; - phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); - + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); + $template->assign_vars(array( 'S_LIST' => true, 'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false, diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index b7be92d477..db4b4263b0 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -927,8 +927,8 @@ class acp_icons } } $db->sql_freeresult($result); - - phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start); + + phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start); } /** diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 1e23c2e6cf..bf7a9e11e4 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -289,8 +289,8 @@ class acp_inactive } $base_url = $this->u_action . "&$u_sort_param&users_per_page=$per_page"; - phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $inactive_count, $per_page, $start); - + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $inactive_count, $per_page, $start); + $template->assign_vars(array( 'S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary), @@ -299,7 +299,6 @@ class acp_inactive 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $inactive_count, $per_page, $start), - 'USERS_PER_PAGE' => $per_page, 'U_ACTION' => $this->u_action . "&$u_sort_param&users_per_page=$per_page&start=$start", diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 4538633d6c..d86521532c 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -131,7 +131,7 @@ class acp_logs $base_url = $this->u_action . "&$u_sort_param$keywords_param"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'L_TITLE' => $l_title, 'L_EXPLAIN' => $l_title_explain, diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 985a12d9ce..82d8ef5cbb 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1159,7 +1159,7 @@ class acp_users $base_url = $this->u_action . "&u=$user_id&$u_sort_param"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'S_FEEDBACK' => true, 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), @@ -2075,7 +2075,7 @@ class acp_users $base_url = $this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'S_ATTACHMENTS' => true, 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4e5be20dbf..2e42dfe94e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2240,7 +2240,6 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star $template->assign_vars(array( 'PER_PAGE' => $per_page, 'ON_PAGE' => $on_page, - 'A_BASE_URL' => addslashes($base_url), )); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 7b3bc82093..151677bcfe 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -103,7 +103,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''); phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); - + $template->assign_vars(array( 'ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index c1724b20d9..f706840492 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -172,8 +172,8 @@ class mcp_logs $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords); $base_url = $this->u_action . "&$u_sort_param$keywords_param"; - phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); + $template->assign_vars(array( 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index bbf618ebef..59cdf3c27e 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -217,7 +217,7 @@ class mcp_notes $base_url = $this->u_action . "&$u_sort_param$keywords_param"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 24e531517c..be18dba944 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -297,10 +297,10 @@ class mcp_pm_reports } } } - + $base_url = $this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); - + // Now display the page $template->assign_vars(array( 'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b44685b8a3..0b195aa9d8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -421,7 +421,7 @@ class mcp_queue $base_url = $this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); - + // Now display the page $template->assign_vars(array( 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 2890cd56e2..f2c5080df5 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -413,7 +413,7 @@ class mcp_reports $base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); - + // Now display the page $template->assign_vars(array( 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index e39e553ab6..62483270c0 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -311,7 +311,7 @@ function mcp_topic_view($id, $mode, $action) { phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $posts_per_page, $start); } - + $template->assign_vars(array( 'TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index aefddb7c01..6a8fb4c5d5 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -177,7 +177,7 @@ class mcp_warn $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index e4c351709b..dc095e7b73 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -171,8 +171,8 @@ class ucp_attachments $db->sql_freeresult($result); $base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir"; - phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); - + phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); + $template->assign_vars(array( 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start), 'TOTAL_ATTACHMENTS' => $num_attachments, diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 1026f24699..625da23736 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -453,7 +453,7 @@ function get_pm_from($folder_id, $folder, $user_id) $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"); phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start); - + $template->assign_vars(array( 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $pm_count, $config['topics_per_page'], $start), 'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f142d182bc..d9ba147c70 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1593,7 +1593,7 @@ switch ($mode) } phpbb_generate_template_pagination($template, $pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start); - + // Generate page $template->assign_vars(array( 'PAGE_NUMBER' => phpbb_on_page($template, $user, $pagination_url, $total_users, $config['topics_per_page'], $start), diff --git a/phpBB/search.php b/phpBB/search.php index 7eda3c4d1d..7d20d8d4a2 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -614,7 +614,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } phpbb_generate_template_pagination($template, $u_search, 'pagination', 'start', $total_match_count, $per_page, $start); - + $template->assign_vars(array( 'SEARCH_TITLE' => $l_search_title, 'SEARCH_MATCHES' => $l_search_matches, @@ -1013,7 +1013,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') )); - + if ($show_results == 'topics') { phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); From 7675d72622cf47789c83c9a243d17b0db37b72d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Oct 2012 22:36:37 +0200 Subject: [PATCH 585/666] [ticket/11014] Fix text for previous/next links in Subsilver2 PHPBB3-11014 --- phpBB/styles/subsilver2/template/pagination.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/subsilver2/template/pagination.html b/phpBB/styles/subsilver2/template/pagination.html index f78bb554fc..a2e023ac22 100644 --- a/phpBB/styles/subsilver2/template/pagination.html +++ b/phpBB/styles/subsilver2/template/pagination.html @@ -1,10 +1,10 @@ {L_GOTO_PAGE} - {pagination.PAGE_NUMBER} + {L_PREVIOUS} {pagination.PAGE_NUMBER} {L_ELLIPSIS} - {pagination.PAGE_NUMBER} + {L_NEXT} {pagination.PAGE_NUMBER} From 7ce43d49d8aadeab7db316741cc9d2503fee844c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Oct 2012 22:38:18 +0200 Subject: [PATCH 586/666] [ticket/11014] Fix IF statements for new template pagination PHPBB3-11014 --- phpBB/styles/subsilver2/template/mcp_footer.html | 2 +- phpBB/styles/subsilver2/template/ucp_groups_manage.html | 2 +- phpBB/styles/subsilver2/template/viewonline_body.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/subsilver2/template/mcp_footer.html b/phpBB/styles/subsilver2/template/mcp_footer.html index b48c244653..280920b148 100644 --- a/phpBB/styles/subsilver2/template/mcp_footer.html +++ b/phpBB/styles/subsilver2/template/mcp_footer.html @@ -3,7 +3,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index ac678895a6..decd40a6de 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -185,7 +185,7 @@
-
diff --git a/phpBB/adm/style/captcha_default_acp_demo.html b/phpBB/adm/style/captcha_default_acp_demo.html index 0b1434f7e0..0f137f28df 100644 --- a/phpBB/adm/style/captcha_default_acp_demo.html +++ b/phpBB/adm/style/captcha_default_acp_demo.html @@ -1,4 +1,4 @@
-

{L_CAPTCHA_PREVIEW_EXPLAIN}
+

{L_CAPTCHA_PREVIEW_EXPLAIN}
{L_PREVIEW}
diff --git a/phpBB/adm/style/captcha_gd_acp.html b/phpBB/adm/style/captcha_gd_acp.html index e2804bbc7d..b333d9205c 100644 --- a/phpBB/adm/style/captcha_gd_acp.html +++ b/phpBB/adm/style/captcha_gd_acp.html @@ -14,32 +14,32 @@ {L_GENERAL_OPTIONS}
-

{L_CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN}
+

{L_CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN}
-

{L_CAPTCHA_GD_X_GRID_EXPLAIN}
+

{L_CAPTCHA_GD_X_GRID_EXPLAIN}
-

{L_CAPTCHA_GD_Y_GRID_EXPLAIN}
+

{L_CAPTCHA_GD_Y_GRID_EXPLAIN}
-

{L_CAPTCHA_GD_WAVE_EXPLAIN}
+

{L_CAPTCHA_GD_WAVE_EXPLAIN}
-

{L_CAPTCHA_GD_3D_NOISE_EXPLAIN}
+

{L_CAPTCHA_GD_3D_NOISE_EXPLAIN}
-

{L_CAPTCHA_GD_FONTS_EXPLAIN}
+

{L_CAPTCHA_GD_FONTS_EXPLAIN}
diff --git a/phpBB/adm/style/captcha_qa_acp.html b/phpBB/adm/style/captcha_qa_acp.html index 4eb46d2d3c..99f3f24f70 100644 --- a/phpBB/adm/style/captcha_qa_acp.html +++ b/phpBB/adm/style/captcha_qa_acp.html @@ -59,7 +59,7 @@
{L_EDIT_QUESTION}
-

{L_QUESTION_STRICT_EXPLAIN}
+

{L_QUESTION_STRICT_EXPLAIN}
diff --git a/phpBB/adm/style/captcha_qa_acp_demo.html b/phpBB/adm/style/captcha_qa_acp_demo.html index 0ea2d6a024..79170e27c6 100644 --- a/phpBB/adm/style/captcha_qa_acp_demo.html +++ b/phpBB/adm/style/captcha_qa_acp_demo.html @@ -1,5 +1,5 @@
-

{L_CONFIRM_QUESTION_EXPLAIN}
+

{L_CONFIRM_QUESTION_EXPLAIN}
diff --git a/phpBB/adm/style/captcha_recaptcha_acp.html b/phpBB/adm/style/captcha_recaptcha_acp.html index 34912c7955..67176ebd07 100644 --- a/phpBB/adm/style/captcha_recaptcha_acp.html +++ b/phpBB/adm/style/captcha_recaptcha_acp.html @@ -13,11 +13,11 @@ {L_GENERAL_OPTIONS}
-

{L_RECAPTCHA_PUBLIC_EXPLAIN}
+

{L_RECAPTCHA_PUBLIC_EXPLAIN}
-

{L_RECAPTCHA_PRIVATE_EXPLAIN}
+

{L_RECAPTCHA_PRIVATE_EXPLAIN}
diff --git a/phpBB/adm/style/custom_profile_fields.html b/phpBB/adm/style/custom_profile_fields.html index 351397d3c7..982356bfa7 100644 --- a/phpBB/adm/style/custom_profile_fields.html +++ b/phpBB/adm/style/custom_profile_fields.html @@ -26,7 +26,7 @@ - {L_DAY}: - {L_MONTH}: - {L_YEAR}: + {L_DAY}{L_COLON} + {L_MONTH}{L_COLON} + {L_YEAR}{L_COLON} diff --git a/phpBB/adm/style/install_convert.html b/phpBB/adm/style/install_convert.html index cf78f30b50..5fec8c4789 100644 --- a/phpBB/adm/style/install_convert.html +++ b/phpBB/adm/style/install_convert.html @@ -86,7 +86,7 @@
-

{checks.TITLE_EXPLAIN}
+

{checks.TITLE_EXPLAIN}
{checks.RESULT}
@@ -109,7 +109,7 @@
-

{options.TITLE_EXPLAIN}
+

{options.TITLE_EXPLAIN}
{options.CONTENT}
diff --git a/phpBB/adm/style/install_header.html b/phpBB/adm/style/install_header.html index e306d8f6bf..6826654ded 100644 --- a/phpBB/adm/style/install_header.html +++ b/phpBB/adm/style/install_header.html @@ -42,7 +42,7 @@ function dE(n, s, type)
- + {S_LANG_SELECT}
diff --git a/phpBB/adm/style/install_install.html b/phpBB/adm/style/install_install.html index 79006fba69..1a809a3588 100644 --- a/phpBB/adm/style/install_install.html +++ b/phpBB/adm/style/install_install.html @@ -20,7 +20,7 @@
-
{checks.TITLE}:
{checks.TITLE_EXPLAIN}
+
{checks.TITLE}{L_COLON}
{checks.TITLE_EXPLAIN}
{checks.RESULT}
@@ -43,7 +43,7 @@
-

{options.TITLE_EXPLAIN}
+

{options.TITLE_EXPLAIN}
{options.CONTENT}
diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index 818889c89b..b5fa46dbf6 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -221,13 +221,13 @@
{new.DIR_PART}
{new.FILE_PART}
-
{L_FILE_USED}: {new.CUSTOM_ORIGINAL} +
{L_FILE_USED}{L_COLON} {new.CUSTOM_ORIGINAL}
-
+
[{new.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -245,11 +245,11 @@
{not_modified.DIR_PART}
{not_modified.FILE_PART}
-
{L_FILE_USED}: {not_modified.CUSTOM_ORIGINAL} +
{L_FILE_USED}{L_COLON} {not_modified.CUSTOM_ORIGINAL}
-
[{not_modified.L_SHOW_DIFF}]{L_BINARY_FILE}
+
[{not_modified.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -266,24 +266,24 @@ {L_STATUS_MODIFIED}
{modified.DIR_PART}
{modified.FILE_PART}
-
{L_FILE_USED}: {modified.CUSTOM_ORIGINAL} +
{L_FILE_USED}{L_COLON} {modified.CUSTOM_ORIGINAL}
-
 
+
 
-
+
-
[{modified.L_SHOW_DIFF}]{L_BINARY_FILE}
+
[{modified.L_SHOW_DIFF}]{L_BINARY_FILE}
-
[{L_SHOW_DIFF_FINAL}] 
+
[{L_SHOW_DIFF_FINAL}] 
-
[{L_SHOW_DIFF_FINAL}] 
+
[{L_SHOW_DIFF_FINAL}] 
@@ -299,13 +299,13 @@
{new_conflict.DIR_PART}
{new_conflict.FILE_PART}
-
{L_FILE_USED}: {new_conflict.CUSTOM_ORIGINAL} +
{L_FILE_USED}{L_COLON} {new_conflict.CUSTOM_ORIGINAL}
-
+
[{new_conflict.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -322,38 +322,38 @@ {L_STATUS_CONFLICT}
{conflict.DIR_PART}
{conflict.FILE_PART}
-
{L_FILE_USED}: {conflict.CUSTOM_ORIGINAL} -
{L_NUM_CONFLICTS}: {conflict.NUM_CONFLICTS} +
{L_FILE_USED}{L_COLON} {conflict.CUSTOM_ORIGINAL} +
{L_NUM_CONFLICTS}{L_COLON} {conflict.NUM_CONFLICTS}
-
+
[{L_DOWNLOAD_CONFLICTS}]
{L_DOWNLOAD_CONFLICTS_EXPLAIN} {L_BINARY_FILE}
-
+
-
 
+
 
-
[{L_SHOW_DIFF_MODIFIED}]
+
[{L_SHOW_DIFF_MODIFIED}]
-
[{L_SHOW_DIFF_MODIFIED}]
+
[{L_SHOW_DIFF_MODIFIED}]
-
[{L_SHOW_DIFF_FINAL}]
+
[{L_SHOW_DIFF_FINAL}]
-
[{L_SHOW_DIFF_FINAL}]
+
[{L_SHOW_DIFF_FINAL}]
@@ -392,7 +392,7 @@
{L_SELECT_DOWNLOAD_FORMAT}
-
+
{RADIO_BUTTONS}
@@ -455,12 +455,12 @@
{L_FTP_SETTINGS}
-
+
{UPLOAD_METHOD}
-

{data.EXPLAIN}
+

{data.EXPLAIN}
diff --git a/phpBB/adm/style/install_update_diff.html b/phpBB/adm/style/install_update_diff.html index b5d25e82f2..ecdc40e157 100644 --- a/phpBB/adm/style/install_update_diff.html +++ b/phpBB/adm/style/install_update_diff.html @@ -223,7 +223,7 @@ table.hrdiff caption span {

{L_SKIP}

- + @@ -231,7 +231,7 @@ table.hrdiff caption span { -
{L_NUM_CONFLICTS}: {NUM_CONFLICTS}
+
{L_NUM_CONFLICTS}{L_COLON} {NUM_CONFLICTS}

diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index f6d0e1025f..f7902e6d2e 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -9,7 +9,7 @@