From 5dac5fdb3b0fa9860054c0d166f904c25578e33a Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 8 Mar 2020 00:46:45 +0100 Subject: [PATCH] [ticket/16394] Fix access array offset in MCP topic approval PHPBB3-16394 --- phpBB/mcp.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/mcp.php b/phpBB/mcp.php index c8fb0233ff..23d2ce7d4e 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -82,25 +82,25 @@ if ($post_id) { // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post $sql = 'SELECT topic_id, forum_id - FROM ' . POSTS_TABLE . " - WHERE post_id = $post_id"; + FROM ' . POSTS_TABLE . ' + WHERE post_id = ' . (int) $post_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $topic_id = (int) $row['topic_id']; - $forum_id = (int) $row['forum_id']; + $topic_id = $row['topic_id'] ?? false; + $forum_id = $row['forum_id'] ?? false; } else if ($topic_id) { $sql = 'SELECT forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . (int) $topic_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $forum_id = (int) $row['forum_id']; + $forum_id = $row['forum_id'] ?? false; } // If the user doesn't have any moderator powers (globally or locally) he can't access the mcp