1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2025-01-31 20:11:38 +01:00

Webklex/php-imap: Query - Chunked - Resolved infinite loop when start chunk > 1

This commit is contained in:
FreeScout 2025-01-16 23:48:41 -08:00
parent 925f9f4bc8
commit 1595be8c0d

View File

@ -438,8 +438,14 @@ class Query {
* @throws RuntimeException
*/
public function chunked(callable $callback, int $chunk_size = 10, int $start_chunk = 1) {
$start_chunk = max($start_chunk,1);
$chunk_size = max($chunk_size,1);
$skipped_messages_count = $chunk_size * ($start_chunk-1);
$available_messages = $this->search();
if (($available_messages_count = $available_messages->count()) > 0) {
$available_messages_count = max($available_messages->count() - $skipped_messages_count,0);
if ($available_messages_count > 0) {
$old_limit = $this->limit;
$old_page = $this->page;