Project

General

Profile

Actions

Bug #83240

closed

TCA field with type=input, eval=date with range is broken, always lower range value is applied because of int cast of incoming value before ISO-8601->unix timestamp conversion.

Added by Leonie Philine over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
Start date:
2017-12-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

Here an example TCA column from tt_products:

        'endtime' => [
            'exclude' => 1,
            'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
            'config' => [
                'type' => 'input',
                'size' => '8',
                'max' => '20',
                'eval' => 'date',
                'checkbox' => '0',
                'default' => '0',
                'range' => [
                    'upper' => mktime(0, 0, 0, 12, 31, 2020),
                    'lower' => mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))
                ]
            ]
        ],

This is correct according to the documentation: https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Input.html#range

However, the core handles ranges (as integer) before it converts the date. Therefore, ranges are now broken for eval=date input columns.

This is caused by: https://docs.typo3.org/typo3cms/extensions/core/Changelog/8.5/Important-77702-CustomRenderTypesForDateAndDatetimeFieldsMustUseISO-8601.html?highlight=date
which also caused the distantly related bug https://forge.typo3.org/issues/82981

What happens is the following:

\TYPO3\CMS\Core\DataHandling\DataHandler::checkValueForInput() checks for the TCA range and compares the $value and $tcaFieldConf['range']['lower'] / ['upper'] both cast to "(int)".
As the incoming date is in ISO-8601, it will look like "2018-01-01T00:00:00+00:00". Casting it to integer to compare with the upper/lower range, the value becomes simply "2018". At this point, the lower end of the range ($tcaFieldConf['range']['lower']) is applied to $value.

Only afterwards, \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval() is called, which then attempts to convert the ISO-8601 string to a unix timestamp - but at this point we already lost our original incoming ISO-8601 string, since the lower range value was already applied.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #77702: Use moment.js and ISO-8601 dates in the backendClosedAndreas Wolf2016-08-30

Actions
Related to TYPO3 Core - Bug #82981: FormEngineValidation: range-checks not working for datetime-fieldsClosed2017-11-13

Actions
Actions #1

Updated by Oliver Hader about 6 years ago

  • Subject changed from Regression: TCA field with type=input, eval=date with range is broken, always lower range value is applied because of int cast of incoming value before ISO-8601->unix timestamp conversion. to TCA field with type=input, eval=date with range is broken, always lower range value is applied because of int cast of incoming value before ISO-8601->unix timestamp conversion.
  • Is Regression set to Yes
Actions #2

Updated by Oliver Hader about 6 years ago

  • Related to Task #77702: Use moment.js and ISO-8601 dates in the backend added
Actions #3

Updated by Oliver Hader about 6 years ago

  • Status changed from New to Accepted
Actions #4

Updated by Oliver Hader about 6 years ago

  • Target version changed from next-patchlevel to 8.7.11
Actions #5

Updated by Gerrit Code Review about 6 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #6

Updated by Gerrit Code Review about 6 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #7

Updated by Gerrit Code Review about 6 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #8

Updated by Gerrit Code Review about 6 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #9

Updated by Gerrit Code Review about 6 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #10

Updated by Gerrit Code Review about 6 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56020

Actions #11

Updated by Gerrit Code Review about 6 years ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56060

Actions #12

Updated by Jigal van Hemert about 6 years ago

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

Updated by Oliver Hader about 6 years ago

  • Related to Bug #82981: FormEngineValidation: range-checks not working for datetime-fields added
Actions #14

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions #15

Updated by Nikita Hovratov over 2 years ago

  • Related to Bug #94621: startime/endtime are forced to "today" after saving added
Actions #16

Updated by Nikita Hovratov over 2 years ago

  • Related to deleted (Bug #94621: startime/endtime are forced to "today" after saving)
Actions

Also available in: Atom PDF