You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test #1
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Test #2
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Test #3
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
imap_open() is called every time, when login is called.
Expected behavior
Imap_open should be called only once.
Screenshots
n/a
Desktop / Server (please complete the following information):
After this change, logout gets called multiple times (via Client and LegacyProtocol destructor), therefore logout should be fixed as well to avoid multiple imap_close invoke on the same resource identifier. The code below handles such case properly.
After all the mentioned changes, the debug output becomes:
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::connect CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::login CALLED
Test #1
Test #2
Test #3
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::__destruct CALLED
Webklex\PHPIMAP\Connection\Protocols\LegacyProtocol::logout CALLED
The text was updated successfully, but these errors were encountered:
Please note, that new Client instance is created every time, therefore active_folder value of Client becomes null during Message instantiation, which at the end will result invalid Message operations.
Describe the bug
LegacyProtocol connects multiple times due to logic error in LegacyProtocol::connected
Used config
Using package default with modification affecting only account host, username and password.
Code to Reproduce
First of all, prepend
echo __METHOD__ . " CALLED\n";
line to the following methods inLegacyProtocol.php
:Output of the test code:
imap_open() is called every time, when login is called.
Expected behavior
Imap_open should be called only once.
Screenshots
n/a
Desktop / Server (please complete the following information):
Additional context
The root cause of the issue is in LegacyProtocol::connected method:
The value of the returned statement is obviously faulty. This code should be refactored to:
After this change, logout gets called multiple times (via Client and LegacyProtocol destructor), therefore logout should be fixed as well to avoid multiple imap_close invoke on the same resource identifier. The code below handles such case properly.
After all the mentioned changes, the debug output becomes:
The text was updated successfully, but these errors were encountered: