aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-12-24 14:04:00 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-12-24 14:04:00 +0000
commitccb3b51048f467cdf3174697886680aa1f965069 (patch)
tree62abef246e38f884e2a7bfd9cd48f177b7d93fd8 /phpBB
parentc2f738215e2b48b8e8e31e0019f27c4b38c8155e (diff)
downloadforums-ccb3b51048f467cdf3174697886680aa1f965069.tar
forums-ccb3b51048f467cdf3174697886680aa1f965069.tar.gz
forums-ccb3b51048f467cdf3174697886680aa1f965069.tar.bz2
forums-ccb3b51048f467cdf3174697886680aa1f965069.tar.xz
forums-ccb3b51048f467cdf3174697886680aa1f965069.zip
Introduced code for cleaning up search_wordmatch and search_wordlist tables upon prune.
git-svn-id: file:///svn/phpbb/trunk@1694 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/prune.php118
1 files changed, 105 insertions, 13 deletions
diff --git a/phpBB/includes/prune.php b/phpBB/includes/prune.php
index a9680dadcf..8d29020d1a 100644
--- a/phpBB/includes/prune.php
+++ b/phpBB/includes/prune.php
@@ -86,27 +86,119 @@ function prune($forum_id, $prune_date)
$sql_post = "post_id IN (" . $sql_post . ")";
$sql = "DELETE FROM " . TOPICS_TABLE . "
- WHERE " . $sql_topics;
+ WHERE $sql_topics";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't delete topics during prune.", "", __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . POSTS_TABLE . "
- WHERE " . $sql_post;
- if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION))
- {
- message_die(GENERAL_ERROR, "Couldn't delete post_text during prune.", "", __LINE__, __FILE__, $sql);
- }
- else
+ WHERE $sql_post";
+ if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) )
{
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
- WHERE " . $sql_post;
- if(!$result = $db->sql_query($sql, END_TRANSACTION))
+ WHERE $sql_post";
+ if( $result = $db->sql_query($sql) )
+ {
+ $sql = "DELETE FROM " . SEARCH_MATCH_TABLE . "
+ WHERE $sql_post";
+ if( !$result = $db->sql_query($sql, END_TRANSACTION) )
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete search matches", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
{
message_die(GENERAL_ERROR, "Couldn't delete post during prune.", "", __LINE__, __FILE__, $sql);
}
}
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete post_text during prune.", "", __LINE__, __FILE__, $sql);
+ }
+
+ //
+ // Remove any words in search wordlist which no longer
+ // appear in posts
+ //
+ switch(SQL_LAYER)
+ {
+ case 'postgresql':
+ $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
+ WHERE word_id NOT IN (
+ SELECT word_id
+ FROM " . SEARCH_MATCH_TABLE . "
+ GROUP BY word_id)";
+ $result = $db->sql_query($sql);
+ if( !$result )
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
+ }
+ break;
+
+ case 'oracle':
+ $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
+ WHERE word_id IN (
+ SELECT w.word_id
+ FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m
+ WHERE w.word_id = m.word_id(+)
+ AND m.word_id IS NULL)";
+ $result = $db->sql_query($sql);
+ if( !$result )
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
+ }
+ break;
+
+ case 'mssql':
+ case 'msaccess':
+ $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
+ WHERE word_id IN (
+ SELECT w.word_id
+ FROM " . SEARCH_WORD_TABLE . " w
+ LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON m.word_id = w.word_id
+ WHERE m.word_id IS NULL)";
+ $result = $db->sql_query($sql);
+ if( !$result )
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete old words from word table", __LINE__, __FILE__, $sql);
+ }
+ break;
+
+ case 'mysql':
+ case 'mysql4':
+ // 0.07s
+ $sql = "SELECT w.word_id
+ FROM " . SEARCH_WORD_TABLE . " w
+ LEFT JOIN " . SEARCH_MATCH_TABLE . " m ON m.word_id = w.word_id
+ WHERE m.word_id IS NULL";
+ if( $result = $db->sql_query($sql) )
+ {
+ if( $db->sql_numrows($result) )
+ {
+ $rowset = array();
+ while( $row = $db->sql_fetchrow($result) )
+ {
+ $rowset[] = $row['word_id'];
+ }
+
+ $word_id_sql = implode(", ", $rowset);
+
+ if( $word_id_sql )
+ {
+ // 0.07s (about 15-20 words)
+ $sql = "DELETE FROM " . SEARCH_WORD_TABLE . "
+ WHERE word_id IN ($word_id_sql)";
+ $result = $db->sql_query($sql);
+ if( !$result )
+ {
+ message_die(GENERAL_ERROR, "Couldn't delete word list entry", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ }
+ }
+ break;
+ }
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_topics = forum_topics - $pruned_topics, forum_posts = forum_posts - $pruned_posts
@@ -116,15 +208,15 @@ function prune($forum_id, $prune_date)
message_die(GENERAL_ERROR, "Couldn't update forum data after prune.", "", __LINE__, __FILE__, $sql);
}
- $returnval = array (
+ return array (
"topics" => $pruned_topics,
"posts" => $pruned_posts);
-
- return $returnval;
}
else
{
- return (array("topics" => 0, "posts" => 0));
+ return array(
+ "topics" => 0,
+ "posts" => 0);
}
}