]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix passing null to strlen 31655/head
authorThomas Citharel <tcit@tcit.fr>
Tue, 22 Mar 2022 09:24:51 +0000 (10:24 +0100)
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>
Thu, 24 Mar 2022 09:56:44 +0000 (09:56 +0000)
$filter can be null as it's the default value passed in
ContactsMenuController.

On PHP 8.1 : strlen(): Passing null to parameter #1 ($string) of type string is deprecated

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
lib/private/Contacts/ContactsMenu/ContactsStore.php
lib/private/Contacts/ContactsMenu/Manager.php

index 5b7a942a2448a50307d035edd67ef3fe6c85a7fb..0ac388ce00a3fb24f4b52fb6c29f8d5f2fe62474 100644 (file)
@@ -107,7 +107,7 @@ class ContactsStore implements IContactsStore {
                }
 
                $allContacts = $this->contactsManager->search(
-                       $filter ?: '',
+                       $filter ?? '',
                        [
                                'FN',
                                'EMAIL'
@@ -146,7 +146,7 @@ class ContactsStore implements IContactsStore {
         *
         * @param IUser $self
         * @param Entry[] $entries
-        * @param string $filter
+        * @param string|null $filter
         * @return Entry[] the filtered contacts
         */
        private function filterContacts(
index cea67735da56fe18c20bead7c2b9ca63ce3edb15..73a5a475d8585445fb5ad851390e3e99acb8e870 100644 (file)
@@ -59,14 +59,14 @@ class Manager {
 
        /**
         * @param IUser $user
-        * @param string $filter
+        * @param string|null $filter
         * @return array
         */
        public function getEntries(IUser $user, $filter) {
                $maxAutocompleteResults = max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT));
                $minSearchStringLength = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0);
                $topEntries = [];
-               if (strlen($filter) >= $minSearchStringLength) {
+               if (strlen($filter ?? '') >= $minSearchStringLength) {
                        $entries = $this->store->getContacts($user, $filter, $maxAutocompleteResults);
 
                        $sortedEntries = $this->sortEntries($entries);