Project

General

Profile

Actions

Bug #72047

closed

Using NumberRangeValidator with startRange/endRange does not work

Added by Stephan Großberndt over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Category:
Extbase
Start date:
2015-12-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
easy
Is Regression:
Yes
Sprint Focus:

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')
    );

Related issues 2 (1 open1 closed)

Follows TYPO3 Core - Bug #58313: NumberRangeValidator - old startRange/endRange don't work anymore in 6.2 (are only deprecated for 6.3)Closed2014-04-29

Actions
Precedes TYPO3 Core - Bug #72136: Make Validator Unit Tests behave like they are used from Domain ModelNew2015-12-09

Actions
Actions #1

Updated by Gerrit Code Review over 8 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

Actions #2

Updated by Gerrit Code Review over 8 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

Actions #3

Updated by Gerrit Code Review over 8 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

Actions #4

Updated by Stephan Großberndt over 8 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

Actions #5

Updated by Gerrit Code Review over 8 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

Actions #6

Updated by Gerrit Code Review over 8 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

Actions #7

Updated by Gerrit Code Review over 8 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

Actions #8

Updated by Stephan Großberndt over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF