aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/prune.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2002-04-02 14:04:18 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2002-04-02 14:04:18 +0000
commit51d9bdeca72e22dfa2f7cecc3e7867b125ee899b (patch)
tree679053f4374226e2bdfb02af19f942b842040354 /phpBB/includes/prune.php
parent374f7adca2dd41e3a20739c74514fbca87a01e55 (diff)
downloadforums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.gz
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.bz2
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.tar.xz
forums-51d9bdeca72e22dfa2f7cecc3e7867b125ee899b.zip
Various updates with any luck they fix a few minor issues without causing new ones ...
git-svn-id: file:///svn/phpbb/trunk@2462 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/prune.php')
-rw-r--r--phpBB/includes/prune.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php
index c59217eea1..84f552ec91 100644
--- a/phpBB/includes/prune.php
+++ b/phpBB/includes/prune.php
@@ -26,6 +26,7 @@ if ( !defined('IN_PHPBB') )
}
require($phpbb_root_path . 'includes/functions_search.'.$phpEx);
+require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
function prune($forum_id, $prune_date)
{
@@ -38,12 +39,13 @@ function prune($forum_id, $prune_date)
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
WHERE t.forum_id = $forum_id
AND t.topic_vote = 0
- AND t.topic_type <> " . POST_ANNOUNCE . "
+ AND t.topic_type <> " . POST_ANNOUNCE . "
AND p.post_id = t.topic_last_post_id";
if ( $prune_date != '' )
{
$sql .= " AND p.post_time < $prune_date";
}
+
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
@@ -76,7 +78,7 @@ function prune($forum_id, $prune_date)
{
$sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($sql_topics)";
- if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
+ if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete topics during prune', '', __LINE__, __FILE__, $sql);
}
@@ -85,7 +87,7 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql);
}
@@ -94,27 +96,21 @@ function prune($forum_id, $prune_date)
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
WHERE post_id IN ($sql_post)";
- if ( !($result = $db->sql_query($sql)) )
+ if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete search matches', '', __LINE__, __FILE__, $sql);
}
remove_search_post($sql_post);
- $sql = "UPDATE " . FORUMS_TABLE . "
- SET forum_topics = forum_topics - $pruned_topics, forum_posts = forum_posts - $pruned_posts
- WHERE forum_id = $forum_id";
- if ( !($result = $db->sql_query($sql)) )
- {
- message_die(GENERAL_ERROR, 'Could not update forum data after prune', '', __LINE__, __FILE__, $sql);
- }
+ sync('forum', $forum_id);
return array ('topics' => $pruned_topics, 'posts' => $pruned_posts);
}
@@ -144,12 +140,12 @@ function auto_prune($forum_id = 0)
if ( $row['prune_freq'] && $row['prune_days'] )
{
$prune_date = time() - ( $row['prune_days'] * 86400 );
- prune($forum_id, $prune_date);
-
$next_prune = time() + ( $row['prune_freq'] * 86400 );
+ $pruned = prune($forum_id, $prune_date);
+
$sql = "UPDATE " . FORUMS_TABLE . "
- SET prune_next = $next_prune
+ SET prune_next = $next_prune
WHERE forum_id = $forum_id";
if ( !$db->sql_query($sql) )
{