Skip to content

Commit

Permalink
Move partial parsing to Base library
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed May 6, 2014
1 parent 4e3d0ec commit d359878
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 14 additions & 0 deletions framework/Imap_Client/lib/Horde/Imap/Client/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,20 @@ public function search($mailbox, $query = null, array $options = array())
throw new InvalidArgumentException('Cannot specify RELEVANCY results if not doing a FUZZY search.');
}

/* Check for partial matching. */
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;
}

$options['partial'] = $pids;
}

/* Optimization - if query is just for a count of either RECENT or
* ALL messages, we can send status information instead. Can't
* optimize with unseen queries because we may cause an infinite loop
Expand Down
14 changes: 2 additions & 12 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -2118,16 +2118,6 @@ 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'];
Expand Down Expand Up @@ -2165,7 +2155,7 @@ protected function _search($query, $options)
$results = array_diff($results, array('ALL'));

$results[] = 'PARTIAL';
$results[] = $pids;
$results[] = $options['partial'];
}
}

Expand Down Expand Up @@ -2216,7 +2206,7 @@ protected function _search($query, $options)
$results = array_diff($results, array('ALL'));

$results[] = 'PARTIAL';
$results[] = $pids;
$results[] = $options['partial'];
}
}

Expand Down

0 comments on commit d359878

Please sign in to comment.