mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Convert strict_search to wildcard property and add psalm docs
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
749935e91b
commit
ae068fb47a
5 changed files with 21 additions and 6 deletions
|
|
@ -108,6 +108,7 @@ class AddressBookImpl implements IAddressBook {
|
|||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* - 'wildcard' - Whether the search should use wildcards
|
||||
* @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* example result:
|
||||
* [
|
||||
|
|
|
|||
|
|
@ -1005,6 +1005,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* - 'wildcard' - Whether the search should use wildcards
|
||||
* @psalm-param array{escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
*/
|
||||
public function search($addressBookId, $pattern, $searchProperties, $options = []): array {
|
||||
|
|
@ -1036,6 +1037,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* @param string $pattern
|
||||
* @param array $searchProperties
|
||||
* @param array $options
|
||||
* @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
|
||||
* @return array
|
||||
*/
|
||||
private function searchByAddressBookIds(array $addressBookIds,
|
||||
|
|
|
|||
|
|
@ -43,8 +43,10 @@ class ContactsManager implements IManager {
|
|||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* - 'enumeration' - Whether user enumeration on system address book is allowed
|
||||
* - 'fullmatch' - Whether matching on full detail in system address book is allowed
|
||||
* - 'enumeration' - (since 23.0.0) Whether user enumeration on system address book is allowed
|
||||
* - 'fullmatch' - (since 23.0.0) Whether matching on full detail in system address book is allowed
|
||||
* - 'strict_search' - (since 23.0.0) Whether the search pattern is full string or partial search
|
||||
* @psalm-param array{escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
*/
|
||||
public function search($pattern, $searchProperties = [], $options = []) {
|
||||
|
|
@ -52,6 +54,7 @@ class ContactsManager implements IManager {
|
|||
$result = [];
|
||||
foreach ($this->addressBooks as $addressBook) {
|
||||
$searchOptions = $options;
|
||||
$strictSearch = array_key_exists('strict_search', $options) && $options['strict_search'] === true;
|
||||
|
||||
if ($addressBook->isSystemAddressBook()) {
|
||||
$fullMatch = !\array_key_exists('fullmatch', $options) || $options['fullmatch'] !== false;
|
||||
|
|
@ -59,7 +62,13 @@ class ContactsManager implements IManager {
|
|||
// Neither full match is allowed, so skip the system address book
|
||||
continue;
|
||||
}
|
||||
$searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false;
|
||||
if ($strictSearch) {
|
||||
$searchOptions['wildcard'] = false;
|
||||
} else {
|
||||
$searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false;
|
||||
}
|
||||
} else {
|
||||
$searchOptions['wildcard'] = !$strictSearch;
|
||||
}
|
||||
|
||||
$r = $addressBook->search($pattern, $searchProperties, $searchOptions);
|
||||
|
|
|
|||
|
|
@ -99,8 +99,10 @@ interface IManager {
|
|||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* - 'enumeration' - Whether user enumeration on system address book is allowed
|
||||
* - 'fullmatch' - Whether matching on full detail in system addresss book is allowed
|
||||
* - 'enumeration' - (since 23.0.0) Whether user enumeration on system address book is allowed
|
||||
* - 'fullmatch' - (since 23.0.0) Whether matching on full detail in system addresss book is allowed
|
||||
* - 'strict_search' - (since 23.0.0) Whether the search pattern is full string or partial search
|
||||
* @psalm-param array{escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* @since 6.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ namespace OCP {
|
|||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* - 'wildcard' - Whether the search should use wildcards
|
||||
* - 'wildcard' - (since 23.0.0) Whether the search should use wildcards
|
||||
* @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* example result:
|
||||
* [
|
||||
|
|
|
|||
Loading…
Reference in a new issue