mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-13 21:26:28 +02:00
[ticket/14616] Fixed auto-prune failing on large forums
PHPBB3-14616
This commit is contained in:
@ -2531,7 +2531,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
|||||||
/**
|
/**
|
||||||
* Prune function
|
* 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;
|
global $db, $phpbb_dispatcher;
|
||||||
|
|
||||||
@ -2573,6 +2573,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";
|
$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
|
* 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);
|
$prune_date = time() - ($prune_days * 86400);
|
||||||
$next_prune = time() + ($prune_freq * 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);
|
||||||
|
|
||||||
|
if ($result['topics'] == 0 && $result['posts'] == 0)
|
||||||
|
{
|
||||||
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
||||||
SET prune_next = $next_prune
|
SET prune_next = $next_prune
|
||||||
WHERE forum_id = $forum_id";
|
WHERE forum_id = $forum_id";
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
|
add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user