Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adopt search to NC 28 filters #2432

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1
### Changed

### Fixed
- Fix search support for Nextcloud 28

# Releases
## [25.0.0-alpha2] - 2023-11-08
Expand Down
7 changes: 6 additions & 1 deletion lib/Search/FeedSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
public function search(IUser $user, ISearchQuery $query): SearchResult
{
$list = [];
$term = strtolower($query->getTerm());
if (method_exists($query, 'getFilter')) {
$term = $query->getFilter('term')?->get() ?? '';
} else {
$term = $query->getTerm();

Check failure on line 65 in lib/Search/FeedSearchProvider.php

View workflow job for this annotation

GitHub Actions / phpstan: Nextcloud pre-release with 8.2

Call to deprecated method getTerm() of class OCP\Search\ISearchQuery: 28.0.0
}
$term = strtolower($term);

foreach ($this->service->findAllForUser($user->getUID()) as $feed) {
if (strpos(strtolower($feed->getTitle()), $term) === false) {
Expand Down
7 changes: 6 additions & 1 deletion lib/Search/FolderSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
public function search(IUser $user, ISearchQuery $query): SearchResult
{
$list = [];
$term = strtolower($query->getTerm());
if (method_exists($query, 'getFilter')) {
$term = $query->getFilter('term')?->get() ?? '';
} else {
$term = $query->getTerm();

Check failure on line 66 in lib/Search/FolderSearchProvider.php

View workflow job for this annotation

GitHub Actions / phpstan: Nextcloud pre-release with 8.2

Call to deprecated method getTerm() of class OCP\Search\ISearchQuery: 28.0.0
}
$term = strtolower($term);

foreach ($this->service->findAllForUser($user->getUID()) as $folder) {
if (strpos(strtolower($folder->getName()), $term) === false) {
Expand Down
12 changes: 9 additions & 3 deletions lib/Search/ItemSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
private function stripTruncate(string $string, int $length = 50): string
{
$string = strip_tags(trim($string));

if (strlen($string) > $length) {
$string = wordwrap($string, $length);
$string = explode("\n", $string, 2);
$string = $string[0];
}

return $string;
}

Expand All @@ -76,13 +76,19 @@
$offset = (int) ($query->getCursor() ?? 0);
$limit = $query->getLimit();

if (method_exists($query, 'getFilter')) {
$term = $query->getFilter('term')?->get() ?? '';
} else {
$term = $query->getTerm();

Check failure on line 82 in lib/Search/ItemSearchProvider.php

View workflow job for this annotation

GitHub Actions / phpstan: Nextcloud pre-release with 8.2

Call to deprecated method getTerm() of class OCP\Search\ISearchQuery: 28.0.0
}

$search_result = $this->service->findAllWithFilters(
$user->getUID(),
ListType::ALL_ITEMS,
$limit,
$offset,
false,
[$query->getTerm()]
[$term]
);

$last = end($search_result);
Expand Down
Loading