Skip to content

FIX ListboxField discarding mised-type values - CMS 6.1#11972

Closed
emteknetnz wants to merge 1 commit intosilverstripe:6.1from
creative-commoners:pulls/6.1/merge-up
Closed

FIX ListboxField discarding mised-type values - CMS 6.1#11972
emteknetnz wants to merge 1 commit intosilverstripe:6.1from
creative-commoners:pulls/6.1/merge-up

Conversation

@emteknetnz
Copy link
Copy Markdown
Member

@emteknetnz emteknetnz commented Feb 25, 2026

Issue #11956

Tricky merge-up, lots of conflict, so redoing solution for CMS 6.1 (different PR from 5.4). Added some extra stuff to for edge cases

  • Adapt 5.4 solution for 6.1 to resolve ListboxField.php conflict while retaining CMS 6 logic
  • Guard ListboxField getValueArray type coercion for mixed-type source values and handle zero scalar inputs
  • Tighten ListboxField schema value decoding to only accept Value or value payloads while preserving mixed-type selections
  • Add regression coverage for numeric-string-first choices and JSON schema values in ListboxFieldTest

CMS 5.4 PR

After merged assign back to Steve to handle the merge-up

@emteknetnz emteknetnz force-pushed the pulls/6.1/merge-up branch 2 times, most recently from 99284c3 to 9afeebb Compare February 26, 2026 02:09
@emteknetnz emteknetnz changed the title Pulls/6.1/merge up FIX ListboxField discarding mised-type values - CMS 6.1 Feb 26, 2026
Copy link
Copy Markdown
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

This code is almost identical to the original PR, except it has some new conditions added and a bunch of new test coverage.

I'm guessing the new conditions are related to "Added some extra stuff to for edge cases"? If so, please indicate what the edge cases were that necessitated each new condition - and why they aren't being handled separately from the merge-up.

if ($trimmed !== '') {
$firstChar = substr($trimmed, 0, 1);
if ($firstChar === '{' || $firstChar === '[') {
if (strpos($trimmed, '"Value"') !== false || strpos($trimmed, '"value"') !== false) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this new condition here for? It's not in the original code on this branch nor in the code being merged up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The if (strpos($trimmed, '"Value"') !== false) { condition is still there - it's not in the original code on this branch nor in the code being merged up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

if (strpos($trimmed, '"Value"') !== false || strpos($trimmed, '"value"') !== false) {
$decoded = json_decode($item, true);
if (is_array($decoded)
&& (array_key_exists('Value', $decoded) || array_key_exists('value', $decoded))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As above

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

&& array_key_exists('Value', $decoded) is still there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Also needs a rebase to resolve conflicts

if ($trimmed !== '') {
$firstChar = substr($trimmed, 0, 1);
if ($firstChar === '{' || $firstChar === '[') {
if (strpos($trimmed, '"Value"') !== false || strpos($trimmed, '"value"') !== false) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The if (strpos($trimmed, '"Value"') !== false) { condition is still there - it's not in the original code on this branch nor in the code being merged up.

if (strpos($trimmed, '"Value"') !== false || strpos($trimmed, '"value"') !== false) {
$decoded = json_decode($item, true);
if (is_array($decoded)
&& (array_key_exists('Value', $decoded) || array_key_exists('value', $decoded))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

&& array_key_exists('Value', $decoded) is still there

@emteknetnz
Copy link
Copy Markdown
Member Author

Rebased

@GuySartorelli
Copy link
Copy Markdown
Member

Looks like you've removed all of the actual source code changes?

@emteknetnz
Copy link
Copy Markdown
Member Author

emteknetnz commented Mar 24, 2026

Funny, it's because I just manually resolved in a merge-up yesterday i.e. the thing I originally raised this PR to avoid doing 😆 5fc3f2d - my changes on this PR mirrored what I did yesterday.

I'll just close this PR

@emteknetnz emteknetnz closed this Mar 24, 2026
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