@@ -1024,6 +1024,8 @@ public function updateShares(IShareable $shareable, $add, $remove) {
10241024 * - 'escape_like_param' - If set to false wildcards _ and % are not escaped, otherwise they are
10251025 * - 'limit' - Set a numeric limit for the search results
10261026 * - 'offset' - Set the offset for the limited search results
1027+ * - 'wildcard' - Whether the search should use wildcards
1028+ * @psalm-param array{escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
10271029 * @return array an array of contacts which are arrays of key-value-pairs
10281030 */
10291031 public function search ($ addressBookId , $ pattern , $ searchProperties , $ options = []): array {
@@ -1055,13 +1057,15 @@ public function searchPrincipalUri(string $principalUri,
10551057 * @param string $pattern
10561058 * @param array $searchProperties
10571059 * @param array $options
1060+ * @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, wildcard?: bool} $options
10581061 * @return array
10591062 */
10601063 private function searchByAddressBookIds (array $ addressBookIds ,
10611064 string $ pattern ,
10621065 array $ searchProperties ,
10631066 array $ options = []): array {
10641067 $ escapePattern = !\array_key_exists ('escape_like_param ' , $ options ) || $ options ['escape_like_param ' ] !== false ;
1068+ $ useWildcards = !\array_key_exists ('wildcard ' , $ options ) || $ options ['wildcard ' ] !== false ;
10651069
10661070 $ query2 = $ this ->db ->getQueryBuilder ();
10671071
@@ -1103,7 +1107,9 @@ private function searchByAddressBookIds(array $addressBookIds,
11031107
11041108 // No need for like when the pattern is empty
11051109 if ('' !== $ pattern ) {
1106- if (!$ escapePattern ) {
1110+ if (!$ useWildcards ) {
1111+ $ query2 ->andWhere ($ query2 ->expr ()->eq ('cp.value ' , $ query2 ->createNamedParameter ($ pattern )));
1112+ } elseif (!$ escapePattern ) {
11071113 $ query2 ->andWhere ($ query2 ->expr ()->ilike ('cp.value ' , $ query2 ->createNamedParameter ($ pattern )));
11081114 } else {
11091115 $ query2 ->andWhere ($ query2 ->expr ()->ilike ('cp.value ' , $ query2 ->createNamedParameter ('% ' . $ this ->db ->escapeLikeParameter ($ pattern ) . '% ' )));
0 commit comments