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

ComponentReflection::convertType() empty string problem #318

Open
romanbartl opened this issue Nov 28, 2023 · 1 comment
Open

ComponentReflection::convertType() empty string problem #318

romanbartl opened this issue Nov 28, 2023 · 1 comment

Comments

@romanbartl
Copy link

romanbartl commented Nov 28, 2023

Hey there,

When you declare persistent variable of int|null type inside of Control, and in URL coresponding parameter is empty string, than type error occurs. From what I've learnt this error happens in ComponentReflection in castScalar() method when you try to check whether data-loss happens. It seems that this peace of code does not count with nullable persistent parameters. It happens because strict typed comparassion.

I would expect that when there is given an empty string in GET/POST, and declared coresponding persistent variable is nullable, than 'null' should be assigned. If it makes sence.

Tested on version: 3.1.17.

@redwormik
Copy link

Hi,

I also encountered this, convertType stopped working for empty-string-to-null/nullable conversion after upgrading.
The behaviour changed in https://github.com/nette/application/releases/tag/v3.1.14 (commit 68783c1#diff-605f970edb9605bf1d71055c0e65624965041ddbbb4b26d27182d936cb640410L202)
The previous behaviour seems unintended, given there are no tests for converting to null

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

No branches or pull requests

2 participants