Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImapProtocol.php:774 - Undefined array key 0 #552

Open
zeddmaster opened this issue Feb 24, 2025 · 0 comments
Open

ImapProtocol.php:774 - Undefined array key 0 #552

zeddmaster opened this issue Feb 24, 2025 · 0 comments
Labels
bug Something isn't working confirmed

Comments

@zeddmaster
Copy link

Describe the bug
When using the chunk function, some messages do not have an element with index 0

Used config
IMAP_HOST=imap.mail.ru
IMAP_PORT=993

Code to Reproduce

My usage:

$mailQuery->chunked(function (MessageCollection $messages) {

            /** @var Message $message */
            foreach ($messages as $message) {
                $mailMessage = MessageSaver::save($message);
                $this->builder->save($mailMessage);
            }
        }, $this->chunkSize);

Vendor src:

// vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:774

public function fetch(array|string $items, array|int $from, mixed $to = null, int|string $uid = IMAP::ST_UID): Response {
        if (is_array($from) && count($from) > 1) {
            $set = implode(',', $from);
        } elseif (is_array($from) && count($from) === 1) {
            $set = $from[0] . ':' . $from[0]; // <-- exception
        } elseif ($to === null) {
            $set = $from . ':' . $from;
        } elseif ($to == INF) {
            $set = $from . ':*';
        } else {
            $set = $from . ':' . (int)$to;
        }
        // ...
}

On dumping $from variable i get this value:

$from = [
  40 => "39083"
];

Screenshots
Image

Desktop / Server (please complete the following information):

  • OS: Ubuntu 22.04
  • PHP: 8.3.17
  • Version: 6.1.0
  • Provider: mail.ru
zeddmaster pushed a commit to zeddmaster/php-imap that referenced this issue Feb 24, 2025
@Webklex Webklex added bug Something isn't working confirmed labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

2 participants