Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fix BC-Break: Default value on multiselect object type introduced by #15871 #16779

Merged
merged 12 commits into from Mar 14, 2024

Conversation

kingjia90
Copy link
Contributor

Changes in this pull request

Resolves #16777

Additional info

@kingjia90 kingjia90 added the Bug label Mar 13, 2024
@kingjia90 kingjia90 added this to the 11.2.1 milestone Mar 13, 2024
Copy link

Review Checklist

  • Target branch (11.2 for bug fixes, others 11.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@kingjia90 kingjia90 marked this pull request as draft March 13, 2024 09:31
@kingjia90
Copy link
Contributor Author

@NiklasBr Thank you for the prompt report of the bc-break related to this topic, could you please have a look and try if this PR could also solve it?

kingjia90 and others added 2 commits March 13, 2024 10:39
Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>
Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>
Comment on lines 130 to 134
if (!$defaultValue) {
$defaultValue = null;
}elseif (is_string($defaultValue)){
$defaultValue = [$defaultValue];
}
Copy link
Contributor

@blankse blankse Mar 13, 2024

Choose a reason for hiding this comment

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

Maybe this? When it is null, it must not be changed, Empty Array should also no problem or?

Suggested change
if (!$defaultValue) {
$defaultValue = null;
}elseif (is_string($defaultValue)){
$defaultValue = [$defaultValue];
}
if (is_string($defaultValue)) {
$defaultValue = $defaultValue !== '' ? [$defaultValue] : null;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

My current project has null and "" and somestring values which broke, I would suspect that perhaps some integers could have made it's way into the default value storage as well. Maybe check for scalar values would make it more forgiving?

And for v12.0 create a migration which forces array type for all while making the type stricter again?

Copy link
Contributor

@blankse blankse Mar 13, 2024

Choose a reason for hiding this comment

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

Where did these defaultValues came from?
Was the field type a single select in the past?
So after the convert in the backend the default value from the single select still exists?

If this is the case, I think we could not make it type strict. This can also possible in v12. We should than also check the case when someone convert the multi select in a single select.

Copy link
Contributor

Choose a reason for hiding this comment

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

They were created using v6 or v10, some could possibly have been selects or other field types at one point as well.

@kingjia90

This comment was marked as resolved.

Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>
@blankse
Copy link
Contributor

blankse commented Mar 13, 2024

@kingjia90 I think we need no if there. The trait is only used on this two classes. So we can remove it. I created a PR to check this:
#16782

blankse and others added 2 commits March 13, 2024 15:47
* Fix SelectionProviderTrait

* Change unneeded getOptions() call by string
Copy link

sonarcloud bot commented Mar 13, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@kingjia90 kingjia90 marked this pull request as ready for review March 13, 2024 14:59
@kingjia90
Copy link
Contributor Author

kingjia90 commented Mar 13, 2024

Should be ready for tagging a release, despite i am still having issues when using it with multiselect within classification stores, but opened a new issue
#16785

@kingjia90 kingjia90 merged commit e4fea5a into 11.2 Mar 14, 2024
17 checks passed
@kingjia90 kingjia90 deleted the hotfix-multiselect branch March 14, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BC-Break: Default value on multiselect object type introduced by #15871
5 participants