1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 13:30:25 +02:00

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
This commit is contained in:
Chris Smith
2009-03-16 22:39:37 +00:00
parent 272cde8251
commit b933bc87e2
2 changed files with 11 additions and 1 deletions

View File

@@ -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();