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

Float in GET params #200

Closed
AndrewHlavac opened this issue May 28, 2018 · 0 comments
Closed

Float in GET params #200

AndrewHlavac opened this issue May 28, 2018 · 0 comments

Comments

@AndrewHlavac
Copy link

@AndrewHlavac AndrewHlavac commented May 28, 2018

Version: 2.4.12

Bug Description

There is a problem when converting float GET params in \Nette\Application\UI\ComponentReflection::convertType(). Because conversion from string to float and back does not have to give the same result, in some cases it ends up with the data-loss check.

Steps To Reproduce

class FooPresenter extends \Nette\Application\UI\Presenter {
  public function actionBar(float $length) {
  }
}

When you call /foo/bar/?length=1.2 everything work as expected.
When you call /foo/bar/?length=1.0 the BadRequestException is thrown.

Expected Behavior

Value 1.0 should be treated as float not string.

Possible Solution

I was not able to find out other solution then handle each scalar type differently.

@dg dg closed this in e1bc262 May 29, 2018
dg added a commit that referenced this issue May 29, 2018
dg added a commit that referenced this issue May 29, 2018
note: gettype() returns 'double', ReflectionType returns 'float'
dg added a commit that referenced this issue May 29, 2018
note: gettype() returns 'double', ReflectionType returns 'float'
dg added a commit that referenced this issue Sep 12, 2018
note: gettype() returns 'double', ReflectionType returns 'float'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.