diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index d66139d977f..79a0368c7cf 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -2118,6 +2118,16 @@ protected function _search($query, $options) } } + if (!empty($options['partial'])) { + $pids = $this->getIdsOb($options['partial'], true)->range_string; + if (!strlen($pids)) { + throw new InvalidArgumentException('Cannot specify empty sequence range for a PARTIAL search.'); + } + if (strpos($pids, ':') === false) { + $pids .= ':' . $pids; + } + } + $charset = is_null($options['_query']['charset']) ? 'US-ASCII' : $options['_query']['charset']; @@ -2154,11 +2164,6 @@ protected function _search($query, $options) /* Can't have both ALL and PARTIAL returns. */ $results = array_diff($results, array('ALL')); - $pids = $this->getIdsOb($options['partial'], true)->range_string; - if (strpos($pids, ':') === false) { - $pids .= ':' . $pids; - } - $results[] = 'PARTIAL'; $results[] = $pids; } @@ -2210,11 +2215,6 @@ protected function _search($query, $options) // Can't have both ALL and PARTIAL returns. $results = array_diff($results, array('ALL')); - $pids = $this->getIdsOb($options['partial'], true)->range_string; - if (strpos($pids, ':') === false) { - $pids .= ':' . $pids; - } - $results[] = 'PARTIAL'; $results[] = $pids; }