From b933bc87e207a5e4c3ddf695e9b65fbb8dbb7079 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 16 Mar 2009 22:39:37 +0000 Subject: 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/includes/functions_admin.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/functions_admin.php') 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(); -- cgit v1.2.1 From e461162847b1ac9287870de680e8dbd17e9f2fc1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 19 Mar 2009 17:01:59 +0000 Subject: Fix race condition for updating post/topic/etc. counter. (reported by BartVB) please do not try such fixes at home - the correct solution would be to create a second config table with integer columns. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9398 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5da18d250c..549f854b78 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -619,7 +619,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s if ($approved_topics) { - set_config('num_topics', $config['num_topics'] - $approved_topics, true); + set_config_count('num_topics', $approved_topics * (-1), true); } return $return; @@ -776,7 +776,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = if ($approved_posts) { - set_config('num_posts', $config['num_posts'] - $approved_posts, true); + set_config_count('num_posts', $approved_posts * (-1), true); } // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too) @@ -903,8 +903,8 @@ function delete_attachments($mode, $ids, $resync = true) if ($space_removed || $files_removed) { - set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true); - set_config('num_files', $config['num_files'] - $files_removed, true); + set_config_count('upload_dir_size', $space_removed * (-1), true); + set_config_count('num_files', $files_removed * (-1), true); } // If we do not resync, we do not need to adjust any message, post, topic or user entries -- cgit v1.2.1 From 77fcc367e2ec60a1ca9a891d6cbcbf48be05badb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 11:10:07 +0000 Subject: SQL optimizations git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9439 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 549f854b78..7aaff2a562 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -652,7 +652,21 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = return false; } - $where_clause = $db->sql_in_set($where_type, array_map('intval', $where_ids)); + $where_ids = array_map('intval', $where_ids); + +/* Possible code for splitting post deletion + if (sizeof($where_ids) >= 1001) + { + // Split into chunks of 1000 + $chunks = array_chunk($where_ids, 1000); + + foreach ($chunks as $_where_ids) + { + delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); + } + }*/ + + $where_clause = $db->sql_in_set($where_type, $where_ids); } $approved_posts = 0; @@ -665,10 +679,10 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = while ($row = $db->sql_fetchrow($result)) { - $post_ids[] = $row['post_id']; - $poster_ids[] = $row['poster_id']; - $topic_ids[] = $row['topic_id']; - $forum_ids[] = $row['forum_id']; + $post_ids[] = (int) $row['post_id']; + $poster_ids[] = (int) $row['poster_id']; + $topic_ids[] = (int) $row['topic_id']; + $forum_ids[] = (int) $row['forum_id']; if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) { -- cgit v1.2.1 From e35b5c26e6a3f2a8a764899eb0b03495aac284e0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 12 Apr 2009 13:21:25 +0000 Subject: Fix skipping messages if using next/prev PM in history links. (Bug #22205) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9441 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_admin.php') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 7aaff2a562..79282c0358 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -664,6 +664,8 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = { delete_posts($where_type, $_where_ids, $auto_sync, $posted_sync, $post_count_sync, $call_delete_topics); } + + return; }*/ $where_clause = $db->sql_in_set($where_type, $where_ids); -- cgit v1.2.1