php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Infinite loop entered when using folder->idle() with Gmail

Open frecco opened this issue 3 years ago • 1 comments

Describe the bug When using $folder->idle() an infinite loop is entered. Happened to discover this since i had Xdebug enabled. It some times worked but when I started deleting mails and moving them around it stopped. Now this happens every time.

Used config No config besides login information.

"Code to Reproduce"

        $client->connect();
        $folder = $client->getFolderByName('INBOX');
        $folder->idle(fn($message) => $this->handleReply($message), $timeout = 1200, $auto_reconnect = false);;

Expected behavior Getting new mesages from INBOX.

Screenshots

PHP Fatal error:  Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:107
Stack trace:
#0 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(107): fgets()
#1 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(136): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->nextLine()
#2 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(235): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->nextTaggedLine()
#3 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(566): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->readLine()
#4 /xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(690): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->getUid()
... repeats ...
#244 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(708): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->getUid()
#245 xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php(708): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->getUid()
#246 xxx/vendor/webklex/php-imap/src/Message.php(1386): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->getUid()
#247 xxx/vendor/webklex/php-imap/src/Message.php(1422): Webklex\PHPIMAP\Message->setMsgn()
#248 xxx/vendor/webklex/php-imap/src/Message.php(211): Webklex\PHPIMAP\Message->setSequenceId()
#249 xxx/vendor/webklex/php-imap/src/Query/Query.php(447): Webklex\PHPIMAP\Message->__construct()
#250 xxx/vendor/webklex/php-imap/src/Query/Query.php(466): Webklex\PHPIMAP\Query\Query->getMessage()
#251 /xxx/vendor/webklex/php-imap/src/Folder.php(384): Webklex\PHPIMAP\Query\Query->getMessageByMsgn()
#252 xxx/CheckMailController.class.php(51): Webklex\PHPIMAP\Folder->idle()
#253 xxx/CheckMailController.class.php(31): XXX\CliController\CheckMailController->checkMail()
#254 xxx/bin/MailMonitor.php(12): XXX\CliController\CheckMailController->run()
#255 /xxx/bin/MailMonitor.php(18): XXX\Cli\MailMonitor->run()
#256 {main}
  thrown in xxx/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php on line 107

Desktop / Server (please complete the following information):

  • OS: Debian 11
  • PHP: 8.1
  • Version v3.2.0
  • Provider Gmail

Additional context Even if a raise the limit to max 1024 frames same thing happens.

frecco avatar May 05 '22 14:05 frecco

Hi @frecco , thanks for your report. I believe to have determined and fixed the issue with the latest release. Please update to >= v4.0.0 and try again.

Best regards & happy coding,

Webklex avatar Aug 19 '22 19:08 Webklex