diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
| commit | a45bca7c49623341ae971d4e1014ba9de38de982 (patch) | |
| tree | a1f033124b14c020e850525a6ea745cb7cb3dbab /phpBB/includes/functions_admin.php | |
| parent | 1f3498c0d6a20a08fe17948b32fc435f85a6eff8 (diff) | |
| parent | 6485d66743d55aeba95aed86fcde4a0e555e3104 (diff) | |
| download | forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.gz forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.bz2 forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.xz forums-a45bca7c49623341ae971d4e1014ba9de38de982.zip | |
Merge commit 'release-3.0.5-RC1'
Diffstat (limited to 'phpBB/includes/functions_admin.php')
| -rw-r--r-- | phpBB/includes/functions_admin.php | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5ec51e44cf..79282c0358 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; @@ -652,7 +652,23 @@ 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); + } + + return; + }*/ + + $where_clause = $db->sql_in_set($where_type, $where_ids); } $approved_posts = 0; @@ -665,10 +681,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']) { @@ -776,7 +792,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) @@ -814,11 +830,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 +861,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 +889,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(); @@ -894,8 +919,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 |
