Project

General

Profile

Actions

Bug #94621

closed

startime/endtime are forced to "today" after saving

Added by Xavier Perseguers almost 3 years ago. Updated over 2 years ago.

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

100%

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

Description

Since v10.4.18 we face a regression when using @'range' on a date/time field.

How to reproduce

Take any TCA definition and put some lower constraint on the range of startime and/or endtime. Here is an example of such a problematic definition (which originates back from many versions of TYPO3):

        'endtime' => [
            'exclude' => 1,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
            'config' => [
                'type' => 'input',
                'size' => 13,
                'eval' => 'datetime',
                'checkbox' => 0,
                'default' => 0,
                'range' => [
                    'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
                ],
                'behaviour' => [
                    'allowLanguageSynchronization' => true,
                ],
                'renderType' => 'inputDateTime',
            ],
        ],

Even if that definition not really makes sense anymore since TCA is cached since TYPO3 v9, this was never a problem but is suddenly breaking (typically) custom records:

  • Create a (or update an existing) record having those starttime, endtime
  • Upon saving the (empty) start/end fields are now populated with the date on midnight (+ GMT/timezone offset) of the day you last cleared the whole cache
  • You CANNOT clear that field again

This is highly breaking because typically for the endtime field, this has impact on records you create/edit and can be particularly weird in relation with IRRE where you don't always see that such a visibility restriction has been enforced.

Analysis

Thanks to Benni, it looks like that the culprit commit is https://git.typo3.org/Packages/TYPO3.CMS.git/blobdiff/ae55eef595bdd4d0676d3b9d96cfc08a4f327527..adce6dbe8b305c71c447929bc14e5c87b4ad6954:/typo3/sysext/core/Classes/DataHandling/DataHandler.php

and particularly (for me, by reading) to this part:

+            && (
+                !isset($tcaFieldConf['default'])
+                || floor($res['value']) !== (int)$tcaFieldConf['default']
+                || ceil($res['value']) !== (int)$tcaFieldConf['default']
+            )

Indeed, there's the use of ceil() and floor() with a strict comparison with an int-cast of the default value. having "0" as value in the field (if empty), leads to floor() and ceil() to return a double which is strictly compared to an int and can logically never be true.

Suggestion

Again, by reading only, not tested so far:

+            && (
+                !isset($tcaFieldConf['default'])
+                || (int)floor($res['value']) !== (int)$tcaFieldConf['default']
+                || (int)ceil($res['value']) !== (int)$tcaFieldConf['default']
+            )

Related issues 6 (0 open6 closed)

Related to TYPO3 Core - Task #94658: Raise typo3/cms-styleguide to 11.4.0Closed2021-07-28

Actions
Related to TYPO3 Core - Bug #94527: Range validation in DataHandler has useless if statement partClosed2021-07-10

Actions
Has duplicate TYPO3 Core - Bug #94603: int-validation in TCA does not accept empty value, when lower-range is definedClosed2021-07-21

Actions
Has duplicate TYPO3 Core - Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensionsClosed2021-07-30

Actions
Has duplicate TYPO3 Core - Bug #94711: Date input with lower range inserts value even if no value is set since TYPO3 10.4.18Closed2021-08-04

Actions
Follows TYPO3 Core - Bug #94103: TCA input range does not work well with eval doubleClosed2021-05-10

Actions
Actions #1

Updated by Xavier Perseguers almost 3 years ago

  • Due date set to 2021-05-11
  • Start date changed from 2021-07-23 to 2021-05-11
  • Follows Bug #94103: TCA input range does not work well with eval double added
Actions #2

Updated by Christian Kuhn almost 3 years ago

  • Has duplicate Bug #94603: int-validation in TCA does not accept empty value, when lower-range is defined added
Actions #3

Updated by Oliver Hader almost 3 years ago

  • Due date deleted (2021-05-11)
  • Start date deleted (2021-05-11)
Actions #4

Updated by Oliver Hader almost 3 years ago

  • Status changed from New to Accepted
Actions #5

Updated by Nikita Hovratov almost 3 years ago

  • Related to Bug #83240: 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
Actions #6

Updated by Nikita Hovratov almost 3 years ago

  • Related to deleted (Bug #83240: 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.)
Actions #7

Updated by Gerrit Code Review almost 3 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/c/Packages/TYPO3.CMS/+/70060

Actions #8

Updated by Gerrit Code Review almost 3 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/c/Packages/TYPO3.CMS/+/70060

Actions #9

Updated by Gerrit Code Review almost 3 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/c/Packages/TYPO3.CMS/+/70060

Actions #10

Updated by Gerrit Code Review over 2 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/c/Packages/TYPO3.CMS/+/70060

Actions #11

Updated by Gerrit Code Review over 2 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/c/Packages/TYPO3.CMS/+/70060

Actions #12

Updated by Gerrit Code Review over 2 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/c/Packages/TYPO3.CMS/+/70060

Actions #13

Updated by Gerrit Code Review over 2 years ago

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

Actions #14

Updated by Christian Kuhn over 2 years ago

  • Related to Task #94658: Raise typo3/cms-styleguide to 11.4.0 added
Actions #15

Updated by Christian Kuhn over 2 years ago

  • Related to Bug #94527: Range validation in DataHandler has useless if statement part added
Actions #16

Updated by Gerrit Code Review over 2 years ago

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

Actions #17

Updated by Gerrit Code Review over 2 years ago

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

Actions #18

Updated by Gerrit Code Review over 2 years ago

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

Actions #19

Updated by Nikita Hovratov over 2 years ago

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

Updated by Gerrit Code Review over 2 years ago

  • Status changed from Resolved to Under Review

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

Actions #21

Updated by Gerrit Code Review over 2 years ago

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

Actions #22

Updated by Nikita Hovratov over 2 years ago

  • Status changed from Under Review to Resolved
Actions #23

Updated by Guido Schmechel over 2 years ago

  • Related to Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions added
Actions #24

Updated by Christian Kuhn over 2 years ago

  • Related to deleted (Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions)
Actions #25

Updated by Christian Kuhn over 2 years ago

  • Has duplicate Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions added
Actions #26

Updated by Wouter Wolters over 2 years ago

  • Has duplicate Bug #94711: Date input with lower range inserts value even if no value is set since TYPO3 10.4.18 added
Actions #27

Updated by Gerrit Code Review over 2 years ago

  • Status changed from Resolved to Under Review

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

Actions #28

Updated by Gerrit Code Review over 2 years ago

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

Actions #29

Updated by Nikita Hovratov over 2 years ago

  • Status changed from Under Review to Resolved
Actions #30

Updated by Benni Mack over 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF