瀏覽代碼

Fix passing null to strlen

$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>
tags/v24.0.0beta1
Thomas Citharel 2 年之前
父節點
當前提交
0456f61c1c
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2
    2
      lib/private/Contacts/ContactsMenu/ContactsStore.php
  2. 2
    2
      lib/private/Contacts/ContactsMenu/Manager.php

+ 2
- 2
lib/private/Contacts/ContactsMenu/ContactsStore.php 查看文件

@@ -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(

+ 2
- 2
lib/private/Contacts/ContactsMenu/Manager.php 查看文件

@@ -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);

Loading…
取消
儲存