aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-07-16 19:49:25 +0200
committerMarc Alexander <admin@m-a-styles.de>2016-07-16 19:49:25 +0200
commit6f109dd1ef2eb652521b93294d5ffda9f1608884 (patch)
tree8d9e813cf47ce7efe99a1990a06d724a3cd8f8fa /phpBB
parent38082c41e371be417e26f375d6f9f207d74cfdde (diff)
parent1c52968df648085af1089a6cd4eb222421111b57 (diff)
downloadforums-6f109dd1ef2eb652521b93294d5ffda9f1608884.tar
forums-6f109dd1ef2eb652521b93294d5ffda9f1608884.tar.gz
forums-6f109dd1ef2eb652521b93294d5ffda9f1608884.tar.bz2
forums-6f109dd1ef2eb652521b93294d5ffda9f1608884.tar.xz
forums-6f109dd1ef2eb652521b93294d5ffda9f1608884.zip
Merge pull request #4374 from TheKigen/ticket/14616
[ticket/14616] Fixed auto-prune failing on large forums
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_admin.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 4ecb7b9354..7d52491086 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;
@@ -2583,9 +2583,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
@@ -2593,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))
@@ -2610,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))
{
@@ -2643,12 +2653,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']);
}