Skip to content

Commit

Permalink
[mms] Better error handling when IMAP connection is prematurely disco…
Browse files Browse the repository at this point in the history
…nnected.

Fixes the 'stdClass::getTimer' error I was never able to reproduce
before
  • Loading branch information
slusarz committed Nov 13, 2014
1 parent ed5d6f0 commit e8c8969
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Expand Up @@ -103,13 +103,22 @@ public function add(Horde_Imap_Client_Interaction_Command $cmd,
* response.
*
* @return Horde_Imap_Client_Interaction_Command Command that was
* completed.
* completed. Returns null
* if tagged response
* is not contained in this
* pipeline object.
*/
public function complete(Horde_Imap_Client_Interaction_Server_Tagged $resp)
{
$cmd = $this->_commands[$resp->tag];
$cmd->response = $resp;
unset($this->_todo[$resp->tag]);
if (isset($this->_commands[$resp->tag])) {
$cmd = $this->_commands[$resp->tag];
$cmd->response = $resp;
unset($this->_todo[$resp->tag]);
} else {
/* This can be reached if a previous pipeline action was aborted,
* e.g. via an Exception. */
$cmd = null;
}

return $cmd;
}
Expand Down
7 changes: 7 additions & 0 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Expand Up @@ -4441,6 +4441,13 @@ protected function _getLine(

case 'Horde_Imap_Client_Interaction_Server_Tagged':
$cmd = $pipeline->complete($server);
if (is_null($cmd)) {
/* This indicates a "dangling" tagged response - it was either
* generated by an aborted previous pipeline object or is the
* result of spurious output by the server. Ignore. */
return $this->_getLine($pipeline);
}

if ($timer = $cmd->getTimer()) {
$this->_debug->info(sprintf(
'Command %s took %s seconds.',
Expand Down
2 changes: 2 additions & 0 deletions framework/Imap_Client/package.xml
Expand Up @@ -21,6 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Better error handling when IMAP connection is prematurely disconnected.
* [mms] Fix regression in listMailboxes() for POP3 servers when &apos;flat&apos; option is true.
</notes>
<contents>
Expand Down Expand Up @@ -2755,6 +2756,7 @@
<date>2014-11-10</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Better error handling when IMAP connection is prematurely disconnected.
* [mms] Fix regression in listMailboxes() for POP3 servers when &apos;flat&apos; option is true.
</notes>
</release>
Expand Down

0 comments on commit e8c8969

Please sign in to comment.