Skip to content

Feat/anwb 5192 update tweakwise modules and tests for multi facet value#156

Open
JeroenvRijn wants to merge 10 commits into
EmicoEcommerce:developfrom
JeroenvRijn:feat/ANWB-5192-update-tweakwise-modules-and-tests-for-multi-facet-value
Open

Feat/anwb 5192 update tweakwise modules and tests for multi facet value#156
JeroenvRijn wants to merge 10 commits into
EmicoEcommerce:developfrom
JeroenvRijn:feat/ANWB-5192-update-tweakwise-modules-and-tests-for-multi-facet-value

Conversation

@JeroenvRijn

@JeroenvRijn JeroenvRijn commented May 19, 2026

Copy link
Copy Markdown

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.

Comment thread src/Model/LandingPage.php
private function normalizeFilterValues(mixed $value): array
{
try {
$filterValue = json_decode($value, true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ahuininga-orisha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants