1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-19 23:32:02 +02:00

[ticket/14616] Fixed auto-prune failing on large forums

PHPBB3-14616
This commit is contained in:
Max Krivanek 2016-06-27 04:20:12 -05:00
parent 9595946508
commit f75a01182f

View File

@ -2531,7 +2531,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
/**
* Prune function
*/
function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true)
function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true, $prune_limit = 0)
{
global $db, $phpbb_dispatcher;
@ -2572,6 +2572,11 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
{
$sql_and .= ' AND topic_status = ' . ITEM_MOVED . " AND topic_last_post_time < $prune_date";
}
if ($prune_limit > 0)
{
$sql_and .= " LIMIT $prune_limit";
}
/**
* Use this event to modify the SQL that selects topics to be pruned
@ -2643,12 +2648,15 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
$prune_date = time() - ($prune_days * 86400);
$next_prune = time() + ($prune_freq * 86400);
prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);
$result = prune($forum_id, $prune_mode, $prune_date, $prune_flags, true, 300);
$sql = 'UPDATE ' . FORUMS_TABLE . "
SET prune_next = $next_prune
WHERE forum_id = $forum_id";
$db->sql_query($sql);
if ($result['topics'] == 0 && $result['posts'] == 0)
{
$sql = 'UPDATE ' . FORUMS_TABLE . "
SET prune_next = $next_prune
WHERE forum_id = $forum_id";
$db->sql_query($sql);
}
add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
}