[1.x] fix(search): coalesce null query before gambits to avoid str_getcsv deprecation - #4812
Merged
Conversation
Contributor
Author
|
I reproduced the exception: The checks say that $query should never be null, but it went null in my case. Details |
Member
|
We do advise to run Flarum 1.x on PHP 8.2+ with deprecations suppressed. The old underlying stack has code we cannot update... This would immediately resolve your problem here. That said, this fix is within our control, so potentially we could merge this. Thinking.... |
Coalesce a null `q` to an empty string in AbstractSearcher::search() rather than in GambitManager::explode(), where the `string` parameter type makes `?? ''` dead code that fails PHPStan. This keeps the gambit chain's type contract intact and also covers an empty/absent `q`. Adds a regression test asserting a null search query does not emit the str_getcsv() null deprecation (fatal on strict PHP 8.1+ setups).
The error handler threw on any E_DEPRECATED emitted during the request, so it was derailed by unrelated framework deprecations on PHP 8.4. Narrow it to the str_getcsv deprecation under test.
PHP 8.5 separately deprecates str_getcsv()'s default $escape argument, which fires on every call regardless of this fix. Match the "Passing null" message specifically so the regression test guards only the null query it covers.
Member
|
Thanks for this @edgeinfinity1 — the bug is real. I've pushed a few commits under the maintainer-edit permission to get it merge-ready:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixed an issue I came across when:
I'm not 100% sure if this is actually core related or my extension issue, but I tested without search related extensions and it persists.
Changes proposed in this pull request:
Reviewers should focus on:
Screenshot
Necessity
Confirmed
composer test).Required changes: