re-add 10 * batch size limit in filesystem purge and support v1 dates for sorting mixed versioned comments

This commit is contained in:
El RIDO 2022-12-12 20:48:36 +01:00
parent 38574f0196
commit e54277f014
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92

View file

@ -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;