Bug #72047
closedUsing NumberRangeValidator with startRange/endRange does not work
100%
Description
#58313 introduced a regression.
If you use
* @validate NumberRange (startRange = 0, endRange = 2)
this will never be checked, but the default values from $this->supportedOptions of minimum/maximum will be used
protected $supportedOptions = array( 'minimum' => array(0, 'The minimum value to accept', 'integer'), 'maximum' => array(PHP_INT_MAX, 'The maximum value to accept', 'integer'), 'startRange' => array(0, 'The minimum value to accept', 'integer'), 'endRange' => array(PHP_INT_MAX, 'The maximum value to accept', 'integer') );
Updated by Gerrit Code Review almost 9 years ago
- Status changed from In Progress to Under Review
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Gerrit Code Review almost 9 years ago
Patch set 2 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Gerrit Code Review almost 9 years ago
Patch set 3 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Stephan Großberndt almost 9 years ago
There is a big problem with validator unit tests: They don't work the way the domain model works.
The options to validate against are set by passing an array(minimum and maximum) to the getMock in `typo3\sysext\extbase\Tests\Unit\Validation\Validator\NumberRangeValidatorTest.php`
and via setOptions(startRange and endRange) in `typo3\sysext\extbase\Tests\Unit\Validation\Validator\BeforeExtbase14\NumberRangeValidatorTest.php` while using them in a domain model works differently:
In `typo3\sysext\extbase\Classes\Validation\Validator\AbstractValidator.php` the given options are MERGED with the `$supportedOptions` of the validator.
This means: the new `NumberRangeValidatorTest` just sets minimum and maximum, the old `BeforeExtbase14\NumberRangeValidatorTest` just sets startRange and endRange and thus both work fine. but they just test with their own of both sets, but not with both.
When you use the `NumberRangeValidator` with minimum/maximum in domain model you actually get `array('minimum' => 'your min value', 'maximum' => 'your max value', 'startRange' => 0, 'endRange' => PHP_INT_MAX)`. This works fine with the current code, because minimum and maximum are checked first!
But when you use `NumberRangeValidator` with startRange/endRange in domain model you actually get `array('minimum' => 0, 'maximum' => PHP_INT_MAX, 'startRange' => 'your min value', 'endRange' => 'your max value')`. This time your settings are just silently ignored and the default values of 'minimum' and 'maximum' are used.
So there are two issues to solve:
- Fix the code in the NumberRangeValidator (https://review.typo3.org/#/c/45109)
- Find a way so the validator options are supplied in a way so they behave like the domain model does
Updated by Gerrit Code Review almost 9 years ago
Patch set 4 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Gerrit Code Review almost 9 years ago
Patch set 5 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Gerrit Code Review almost 9 years ago
Patch set 6 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45109
Updated by Stephan Großberndt almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 141cd7dc359c50889dcd9aa7aa28b2466f27cbd0.