From e54277f0145337dec8228ea1eb5301a2fc926300 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 12 Dec 2022 20:48:36 +0100 Subject: [PATCH] re-add 10 * batch size limit in filesystem purge and support v1 dates for sorting mixed versioned comments --- lib/Data/Filesystem.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 0f81541..3266f01 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -228,7 +228,13 @@ class Filesystem extends AbstractData $comment['parentid'] = $items[2]; // Store in array - $key = $this->getOpenSlot($comments, (int) $comment['meta']['created']); + $key = $this->getOpenSlot( + $comments, ( + (int) array_key_exists('created', $comment['meta']) ? + $comment['meta']['created'] : // v2 comments + $comment['meta']['postdate'] // v1 comments + ) + ); $comments[$key] = $comment; } } @@ -358,6 +364,8 @@ class Filesystem extends AbstractData { $pastes = array(); $count = 0; + $opened = 0; + $limit = $batchsize * 10; // try at most 10 times $batchsize pastes before giving up $time = time(); foreach ($this->_getPasteIterator() as $file) { if ($file->isDir()) { @@ -371,11 +379,13 @@ class Filesystem extends AbstractData $data['meta']['expire_date'] < $time ) { $pastes[] = $pasteid; - ++$count; - if ($count >= $batchsize) { + if (++$count >= $batchsize) { break; } } + if (++$opened >= $limit) { + break; + } } } return $pastes;