ddmobley
08-28-2007, 10:18 PM
I am looking for a mod to cleanup2.php in the includes/cron directory that deals with cleaning up the post_parsed cache.
The current code looks like this:
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "post_parsed
WHERE dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24))
);
What I want is to modify this code where it also compares the sticky field in the thread table. If the thread is sticky then the postid in post_parsed which matches the firstpostid of the sticky thread would not be deleted.
Is this doable?
I believe I have written my own solution. If anyone sees anything wrong with this, please respond. I modified the code above to look like this:
// expired cached posts
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "post_parsed
WHERE dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24)) . "
AND NOT EXISTS (SELECT firstpostid FROM " . TABLE_PREFIX . "thread WHERE firstpostid = postid)"
);
This is my latest code:
$vbulletin->db->query_write("
DELETE parsed FROM " . TABLE_PREFIX . "post_parsed AS parsed
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.firstpostid = parsed.postid
WHERE parsed.dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24)) . "
AND thread.sticky = 0"
);
The current code looks like this:
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "post_parsed
WHERE dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24))
);
What I want is to modify this code where it also compares the sticky field in the thread table. If the thread is sticky then the postid in post_parsed which matches the firstpostid of the sticky thread would not be deleted.
Is this doable?
I believe I have written my own solution. If anyone sees anything wrong with this, please respond. I modified the code above to look like this:
// expired cached posts
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "post_parsed
WHERE dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24)) . "
AND NOT EXISTS (SELECT firstpostid FROM " . TABLE_PREFIX . "thread WHERE firstpostid = postid)"
);
This is my latest code:
$vbulletin->db->query_write("
DELETE parsed FROM " . TABLE_PREFIX . "post_parsed AS parsed
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.firstpostid = parsed.postid
WHERE parsed.dateline < " . (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 * 60 * 24)) . "
AND thread.sticky = 0"
);