Skip to content

Commit

Permalink
search: Fix on PHP 8.4
Browse files Browse the repository at this point in the history
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 <https://www.php.net/manual/en/function.str-getcsv.php>, relying on the default value of escape is now deprecated.

Also add a test to ensure search continues to work.
  • Loading branch information
jtojnar committed Feb 22, 2025
1 parent 76383e1 commit f0e5f7b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/helpers/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/helpers/selfoss_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 5 additions & 0 deletions tests/integration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit f0e5f7b

Please sign in to comment.