From f0e5f7b734577844964b1c13baca248c59df16ad Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 22 Feb 2025 01:14:09 +0100 Subject: [PATCH] search: Fix on PHP 8.4 On PHP 8.4 search would fail with the following: str_getcsv(): the $escape parameter must be provided as its default value will change As per , relying on the default value of escape is now deprecated. Also add a test to ensure search continues to work. --- src/helpers/Search.php | 2 +- tests/integration/helpers/selfoss_api.py | 3 ++- tests/integration/run.py | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/helpers/Search.php b/src/helpers/Search.php index 7ae96d5c68..c871d7f0db 100644 --- a/src/helpers/Search.php +++ b/src/helpers/Search.php @@ -24,7 +24,7 @@ public static function splitTerms(string $search): array { // Split search terms by space (but save it inside quotes)... /** @var string[] */ // For PHPStan: The only case where null appears is array{null} when the $string is empty. - $parts = str_getcsv(trim($search), ' '); + $parts = str_getcsv(trim($search), ' ', '"', '\\'); return array_filter( $parts, diff --git a/tests/integration/helpers/selfoss_api.py b/tests/integration/helpers/selfoss_api.py index 84af951524..536be5dc6d 100644 --- a/tests/integration/helpers/selfoss_api.py +++ b/tests/integration/helpers/selfoss_api.py @@ -34,9 +34,10 @@ def logout(self): return r.json() - def get_items(self): + def get_items(self, **params): r = self.session.get( f"{self.base_uri}/items", + params=params, ) r.raise_for_status() diff --git a/tests/integration/run.py b/tests/integration/run.py index dea6251432..81472a52ae 100644 --- a/tests/integration/run.py +++ b/tests/integration/run.py @@ -57,6 +57,11 @@ def test_basic_workflow(self): assert not items[0]["unread"], "First item should now be marked as read" assert items[0]["starred"], "First item should now be starred" + items = selfoss_api.get_items(search="3") + assert ( + len(items) == 5 + ), "Search should find five fibonacci sequence numbers containing the digit 3" + if __name__ == "__main__": unittest.main()