Feat/anwb 5192 update tweakwise modules and tests for multi facet value#156
Open
JeroenvRijn wants to merge 10 commits into
Conversation
Merge beta into master
fix: cast to int for PHP 8.4 compatibility
Merge beta into master
…d-tests-for-multi-facet-value
ahuininga-orisha
requested changes
May 22, 2026
| private function normalizeFilterValues(mixed $value): array | ||
| { | ||
| try { | ||
| $filterValue = json_decode($value, true); |
Collaborator
There was a problem hiding this comment.
json_decode() does not throw a TypeError — it returns null on invalid JSON. The try/catch (TypeError $e) block is dead code
Also: if json_decode decodes a non-array scalar (e.g. the string "42" decodes to integer 42), is_array($filterValue) is false, is_string($filterValue) is also false, and the function falls through to is_string($value) and wraps the original string — correct by accident, not by design.
Suggestion:
private function normalizeFilterValues(mixed $value): array
{
if (is_array($value)) {
return $value;
}
if (!is_string($value) || $value === '') {
return [];
}
$decoded = json_decode($value, true);
return is_array($decoded) ? $decoded : [$value];
}
ahuininga-orisha
approved these changes
May 27, 2026
ahuininga-orisha
left a comment
Collaborator
There was a problem hiding this comment.
Note, only merge/release with EmicoEcommerce/Magento2AttributeLandingTweakwise#61
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.
Updated logic to support multiple facet values to be selected and saved. Also added legacy support for single values saved.
With breaking changes for filter values being returned as array instead of string
Needs to be a MAJOR version update.