Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fixed search string = operator returning an array instead of a string#3373

Open
TowyTowy wants to merge 1 commit into
akaunting:masterakaunting/akaunting:masterfrom
TowyTowy:fix/search-string-equals-operatorTowyTowy/akaunting:fix/search-string-equals-operatorCopy head branch name to clipboard
Open

Fixed search string = operator returning an array instead of a string#3373
TowyTowy wants to merge 1 commit into
akaunting:masterakaunting/akaunting:masterfrom
TowyTowy:fix/search-string-equals-operatorTowyTowy/akaunting:fix/search-string-equals-operatorCopy head branch name to clipboard

Conversation

@TowyTowy

Copy link
Copy Markdown
Contributor

getSearchStringValue() documents that both : and = are single-value (exact-match) operators returning a string, while > < >= <= are range operators that accumulate into an array. The early return only checked for :, so a = filter (e.g. type=customer, account_id=5) fell through and was returned as a one-element array.

This breaks callers expecting a string — e.g. explode(',', $this->getSearchStringValue('account_id')) in app/Abstracts/Listeners/Report.php throws a TypeError (HTTP 500) when a report is filtered with account_id=5.

Fix: detect the operator immediately after the column name so a leading = is matched while the = inside >=/<= is not, restoring the documented single-value behaviour for = without affecting range operators.

Verified on PHP 8.5 with a harness exercising the real trait: type=customer and account_id=5 now return strings (previously arrays), the report explode() path no longer crashes, and >/</>=/<= ranges still return arrays.

AI-assisted fix, reviewed and tested before submitting.

getSearchStringValue() documents that both : and = are single-value
(exact match) operators and should return a string, while > < >= <=
are range operators that accumulate into an array. The early return
only checked for : (str_contains($column, ':')), so a = filter such
as type=customer or account_id=5 fell through to the range branch and
was returned as a one-element array.

This breaks callers that expect a string, e.g. explode(',', $this->
getSearchStringValue('account_id')) in Abstracts/Listeners/Report.php
throws a TypeError (HTTP 500) when a report is filtered with account_id=5.

Detect the operator right after the column name so a leading = is
matched while the = inside >= / <= is not, restoring the documented
single-value behaviour for = without affecting range operators.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.