From 10330e586719b785cdb35ae05a4bb9533558d409 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 15 Aug 2023 11:07:40 +0200 Subject: [PATCH] [ticket/17029] Fall back to redirecting to topic when post id is invalid PHPBB3-17029 --- phpBB/includes/functions_posting.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 2c64685d61..5a490184ec 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2872,7 +2872,14 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $ $delete_reason )); - $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id"; + if ($next_post_id > 0) + { + $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id"; + } + else + { + $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id"); + } $message = $user->lang['POST_DELETED']; if (!$request->is_ajax())