From b933bc87e207a5e4c3ddf695e9b65fbb8dbb7079 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 16 Mar 2009 22:39:37 +0000 Subject: [PATCH] Deleting private message attachments could delete post attachments. #42815 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9379 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 3 ++- phpBB/includes/functions_admin.php | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index f43d08c8e1..ab3f01af71 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -120,6 +120,7 @@
  • [Fix] Fix wrong bot ip check if bot ip was wrongly entered by admin. (Bug #42485)
  • [Fix] Fix javascript errors in simple header (prosilver) by adding forum_fn.js and the corresponding variables. (Bug #42135)
  • [Fix] Set connection encoding for MySQL versions 4.1.0 to 4.1.2. This may fix some conversion issues with special characters. (Bug #41805)
  • +
  • [Fix] Deleting private message attachments could delete post attachments. (Bug #42815)
  • [Change] Allow download of conflicting file for later reference in automatic updater
  • [Change] Default difference view is now 'inline' instead of 'side by side'
  • [Change] Added new option for merging differences to conflicting files in automatic updater
  • @@ -861,4 +862,4 @@ - \ No newline at end of file + diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5ec51e44cf..5da18d250c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -814,11 +814,14 @@ function delete_attachments($mode, $ids, $resync = true) return false; } + $sql_where = ''; + switch ($mode) { case 'post': case 'message': $sql_id = 'post_msg_id'; + $sql_where = ' AND in_message = ' . ($mode == 'message' ? 1 : 0); break; case 'topic': @@ -842,6 +845,9 @@ function delete_attachments($mode, $ids, $resync = true) $sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set($sql_id, $ids); + + $sql .= $sql_where; + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -867,6 +873,9 @@ function delete_attachments($mode, $ids, $resync = true) // Delete attachments $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set($sql_id, $ids); + + $sql .= $sql_where; + $db->sql_query($sql); $num_deleted = $db->sql_affectedrows();