From: Michael M Slusarz Date: Tue, 3 Mar 2009 22:18:25 +0000 (-0700) Subject: Fixes to improve POP3 compatibility X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fa9d808aed7719bf67ed5f4395ad91adb2c83ce5;p=horde.git Fixes to improve POP3 compatibility --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index 5881105ec..27b9eff80 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -1779,6 +1779,11 @@ abstract class Horde_Imap_Client_Base $qresync = isset($this->_init['enabled']['QRESYNC']); $seq = !empty($options['sequence']); + /* Make sure 'ids' is defined. */ + if (!isset($options['ids'])) { + $options['ids'] = array(); + } + /* The 'vanished' modifier requires QRESYNC, 'changedsince', and * !'sequence'. */ if (!empty($options['vanished']) && @@ -1793,15 +1798,17 @@ abstract class Horde_Imap_Client_Base * information (RFC 3501 [6.4.8]). Don't add to criteria because it * simply creates a longer FETCH command. */ - /* If using cache, we store by UID so we need to return UIDs. */ - if ($seq && !empty($cf)) { - $criteria[Horde_Imap_Client::FETCH_UID] = true; - } - $this->openMailbox($mailbox, Horde_Imap_Client::OPEN_AUTO); - /* We need the UIDVALIDITY for the current mailbox. */ - $status_res = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY); + if (!empty($cf)) { + /* We need the UIDVALIDITY for the current mailbox. */ + $status_res = $this->status($this->_selected, Horde_Imap_Client::STATUS_HIGHESTMODSEQ | Horde_Imap_Client::STATUS_UIDVALIDITY); + + /* If using cache, we store by UID so we need to return UIDs. */ + if ($seq) { + $criteria[Horde_Imap_Client::FETCH_UID] = true; + } + } /* Determine if caching is available and if anything in $criteria is * cacheable. Do some sanity checking on criteria also. */ diff --git a/framework/Imap_Client/test/Horde/Imap/test_client.php b/framework/Imap_Client/test/Horde/Imap/test_client.php index 070dfe6ce..1ce70cb71 100644 --- a/framework/Imap_Client/test/Horde/Imap/test_client.php +++ b/framework/Imap_Client/test/Horde/Imap/test_client.php @@ -3,10 +3,11 @@ * Test script for the Horde_Imap_Client:: library. * * Usage: - * test_client.php [[username] [[password] [[IMAP URL]]]] + * test_client.php [[username] [[password] [[IMAP URL] [driver]]]] * * Username/password/hostspec on the command line will override the $params * values. + * Driver on the command line will override the $driver value. * * TODO: * + Test for 'charset' searching @@ -83,9 +84,13 @@ if (!empty($argv[3])) { $params = array_merge($params, $imap_utils->parseUrl($argv[3])); } -function exception_handler($exception) { +if (!empty($argv[4])) { + $driver = $argv[4]; +} + +function exception_handler($e) { print "\n=====================================\n" . - 'UNCAUGHT EXCEPTION: ' . $exception->getMessage() . + 'UNCAUGHT EXCEPTION: ' . $e->getMessage() . "\n=====================================\n"; } set_exception_handler('exception_handler'); @@ -100,7 +105,10 @@ $params['id'] = array('name' => 'Horde_Imap_Client test program'); $imap_client = Horde_Imap_Client::getInstance($driver, $params); if ($driver == 'Cclient_Pop3') { + $pop3 = true; $test_mbox = $test_mbox_utf8 = 'INBOX'; +} else { + $pop3 = false; } $use_imapproxy = false; @@ -562,11 +570,14 @@ try { $simple_fetch = array( Horde_Imap_Client::FETCH_STRUCTURE => true, Horde_Imap_Client::FETCH_ENVELOPE => true, - Horde_Imap_Client::FETCH_FLAGS => true, Horde_Imap_Client::FETCH_DATE => true, Horde_Imap_Client::FETCH_SIZE => true ); +if (!$pop3) { + $simple_fetch[Horde_Imap_Client::FETCH_FLAGS] = true; +} + print "\nSimple fetch example:\n"; try { print_r($imap_client->fetch($test_mbox, $simple_fetch)); @@ -706,7 +717,7 @@ try { print "Fetch: FAILED\n"; // If POP3, try easier fetch criteria - if ($driver == 'Cclient_Pop3') { + if ($pop3) { try { print_r($imap_client->fetch('INBOX', array( Horde_Imap_Client::FETCH_FULLMSG => array(