-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
BUGFIX: Ensure that only numerical property values are converted to integer #3535
BUGFIX: Ensure that only numerical property values are converted to integer #3535
Conversation
…nteger Otherwise, default to `null`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you ;)
Looks good for know. In the future (Neos 9) id like to have strict validation via ajax directly in the editor. (And we could make our NodePropertyConversion thing more strict by throwing exceptions ...)
Tested it, and after fixing also the before Bildschirmaufnahme.2023-07-05.um.08.15.44.movafter Bildschirmaufnahme.2023-07-05.um.08.26.15.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the more annoying issue (that ought to be fixed for LTS imho) is #3157 (unsetting an optional integer value is impossible).
Very good point, take my vote :)
fixes: #3158, #3157
The problem
The UI's
NodePropertyConversionService
over-generalizes when converting incoming values to integer. It just casts any incomingstring
toint
via(int) $someValue
.Now, PHP throws no error if the value we're casting to
int
actually cannot be meaningfully converted. So, pretty much anything it cannot make sense of ends up being0
:The solution
I adjusted the method
convertInteger
ofNodePropertyConversionService
to only convert strings to integers that pass PHP'sis_numerical
check.In case the string doesn't pass,
convertInteger
now defaults tonull
.Because of this, I needed to adjust the
TextFieldEditor
component, so that it now handles the occurrence ofnull
-values correctly.As a result, if I enter a non-numerical string into a text field for a property of type
integer
, the property will receivenull
as a value. The same thing happens, if I enter an empty string.