From f75a01182f04ed4c5a80fbb2edfa3e648605a694 Mon Sep 17 00:00:00 2001 From: Max Krivanek Date: Mon, 27 Jun 2016 04:20:12 -0500 Subject: [ticket/14616] Fixed auto-prune failing on large forums PHPBB3-14616 --- phpBB/includes/functions_admin.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 4ecb7b9354..adc96c6dd4 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -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']); } -- cgit v1.2.1 From 91702618852de42daebd0150f9bb2979e1aa6fa9 Mon Sep 17 00:00:00 2001 From: Max Krivanek Date: Mon, 27 Jun 2016 04:42:01 -0500 Subject: [ticket/14616] Removed misplaced tab. PHPBB3-14616 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index adc96c6dd4..70fff2da59 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2572,7 +2572,7 @@ 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"; -- cgit v1.2.1 From 65a4f0d631c9661341bb0da4ff04c46113ad8048 Mon Sep 17 00:00:00 2001 From: Max Krivanek Date: Tue, 28 Jun 2016 20:47:46 -0500 Subject: [ticket/14616] Added prune_limit to event core.prune_sql PHPBB3-14616 --- phpBB/includes/functions_admin.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 70fff2da59..5e40c86c65 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2588,9 +2588,19 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync * @var int prune_flags The prune flags * @var bool auto_sync Whether or not to perform auto sync * @var string sql_and SQL text appended to where clause + * @var int prune_limit The prune limit * @since 3.1.3-RC1 + * @changed 3.1.10-RC1 Added prune_limit */ - $vars = array('forum_id', 'prune_mode', 'prune_date', 'prune_flags', 'auto_sync', 'sql_and'); + $vars = array( + 'forum_id', + 'prune_mode', + 'prune_date', + 'prune_flags', + 'auto_sync', + 'sql_and', + 'prune_limit' + ); extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars))); $sql = 'SELECT topic_id -- cgit v1.2.1 From c4b93c9c1c7c820cdefaaeb7f6e9101eeda233a8 Mon Sep 17 00:00:00 2001 From: Max Krivanek Date: Fri, 1 Jul 2016 04:09:42 -0500 Subject: [ticket/14616] Added comma expected by test scripts. PHPBB3-14616 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5e40c86c65..323825d4cc 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2599,7 +2599,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync 'prune_flags', 'auto_sync', 'sql_and', - 'prune_limit' + 'prune_limit', ); extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars))); -- cgit v1.2.1 From 1c52968df648085af1089a6cd4eb222421111b57 Mon Sep 17 00:00:00 2001 From: Max Krivanek Date: Wed, 6 Jul 2016 23:00:35 -0500 Subject: [ticket/14616] Switch prune limit to sql_query_limit instead of sql_and PHPBB3-14616 --- phpBB/includes/functions_admin.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'phpBB') diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 323825d4cc..7d52491086 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2573,11 +2573,6 @@ 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 * @@ -2608,7 +2603,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync WHERE ' . $db->sql_in_set('forum_id', $forum_id) . " AND poll_start = 0 $sql_and"; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $prune_limit); $topic_list = array(); while ($row = $db->sql_fetchrow($result)) @@ -2625,7 +2620,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync AND poll_start > 0 AND poll_last_vote < $prune_date $sql_and"; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $prune_limit); while ($row = $db->sql_fetchrow($result)) { -- cgit v1.2.1