From 154ebc24c20339b43eb1adcce947e01cacf9ab46 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sun, 12 Apr 2020 13:39:41 +0200 Subject: [PATCH 1/2] [ticket/15560] Correct redirect on perma-deleting posts PHPBB3-15560 --- phpBB/includes/mcp/mcp_main.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 744eaebd7d..bf9c8ec1b4 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1049,6 +1049,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $redirect = $request->variable('redirect', build_url(array('action', 'quickmod'))); $forum_id = $request->variable('f', 0); + $topic_id = 0; $s_hidden_fields = array( 'post_id_list' => $post_ids, @@ -1122,8 +1123,6 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', )); } - $topic_id = $request->variable('t', 0); - // Return links $return_link = array(); if ($affected_topics == 1 && $topic_id) @@ -1152,7 +1151,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $topic_id_list = array(); while ($row = $db->sql_fetchrow($result)) { - $topic_id_list[] = $row['topic_id']; + $topic_id_list[] = $topic_id = $row['topic_id']; } $affected_topics = count($topic_id_list); $db->sql_freeresult($result); @@ -1183,8 +1182,6 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $deleted_topics = ($row = $db->sql_fetchrow($result)) ? ($affected_topics - $row['topics_left']) : $affected_topics; $db->sql_freeresult($result); - $topic_id = $request->variable('t', 0); - // Return links $return_link = array(); if ($affected_topics == 1 && !$deleted_topics && $topic_id) @@ -1203,6 +1200,12 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', } else { + // Remove any post id anchor + if ($anchor_pos = (strrpos($redirect, '#p')) !== false) + { + $redirect = substr($redirect, 0, $anchor_post); + } + $success_msg = $user->lang['POST_DELETED_SUCCESS']; } } @@ -1260,7 +1263,6 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } - $redirect = $request->variable('redirect', "index.$phpEx"); $redirect = reapply_sid($redirect); if (!$success_msg) From 5ca9674cedee4b302524c46c4534d72098c99884 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sun, 12 Apr 2020 13:44:04 +0200 Subject: [PATCH 2/2] [ticket/15560] Remove correct anchor_pos variable name PHPBB3-15560 --- phpBB/includes/mcp/mcp_main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index bf9c8ec1b4..5c381bfc14 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1203,7 +1203,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', // Remove any post id anchor if ($anchor_pos = (strrpos($redirect, '#p')) !== false) { - $redirect = substr($redirect, 0, $anchor_post); + $redirect = substr($redirect, 0, $anchor_pos); } $success_msg = $user->lang['POST_DELETED_SUCCESS'];