barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.65k stars 459 forks source link

[BUG] Fatal error: Uncaught ValueError: IMAP\Connection is already closed #680

Closed eddi13 closed 1 year ago

eddi13 commented 1 year ago

PHP Fatal error: Uncaught ValueError: IMAP\Connection is already closed in .../PhpImap/Mailbox.php:479 Stack trace:

0 .../PhpImap/Mailbox.php(479): imap_ping()

1 .../PhpImap/Mailbox.php(544): PhpImap\Mailbox->hasImapStream()

2 .../PhpImap/Mailbox.php(187): PhpImap\Mailbox->disconnect()

ghnp5 commented 1 year ago

I'm getting the same since the upgrade to PHP 8.1.11

ghnp5 commented 1 year ago

Probably because of this: https://www.php.net/ChangeLog-8.php

Version 8.1.10

IMAP: Fixed bug GH-9309 (Segfault when connection is used after imap_close()).

ghnp5 commented 1 year ago

To me, this happens because I'm calling unset($mailbox) which calls $mailbox->destruct() which will try to close the IMAP connection which I've already closed by invoking $mailbox->disconnect().

underdpt commented 1 year ago

I can confirm this happens also with version 8.1.13.

Sebbo94BY commented 1 year ago

Should be fixed in version 5.0.1.

applibs commented 1 year ago

And what about: public static function ping($imap_stream): bool in Imap class?