Bug #94621
closedstartime/endtime are forced to "today" after saving
100%
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'] + )
Updated by Xavier Perseguers over 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
Updated by Christian Kuhn over 3 years ago
- Has duplicate Bug #94603: int-validation in TCA does not accept empty value, when lower-range is defined added
Updated by Oliver Hader over 3 years ago
- Due date deleted (
2021-05-11) - Start date deleted (
2021-05-11)
Updated by Nikita Hovratov over 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
Updated by Nikita Hovratov over 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.)
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Christian Kuhn over 3 years ago
- Related to Task #94658: Raise typo3/cms-styleguide to 11.4.0 added
Updated by Christian Kuhn over 3 years ago
- Related to Bug #94527: Range validation in DataHandler has useless if statement part added
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Nikita Hovratov over 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 2d04af91b925465e0a5a4733b51a7457b2ae4217.
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Nikita Hovratov over 3 years ago
- Status changed from Under Review to Resolved
Applied in changeset bd167fcfa4e557983f788fb4ef65d8ae0dbb843d.
Updated by Guido Schmechel over 3 years ago
- Related to Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions added
Updated by Christian Kuhn over 3 years ago
- Related to deleted (Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions)
Updated by Christian Kuhn over 3 years ago
- Has duplicate Bug #94676: starttime/endtime is set automatically in 10.4.18 in serveral extensions added
Updated by Wouter Wolters over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Gerrit Code Review over 3 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
Updated by Nikita Hovratov over 3 years ago
- Status changed from Under Review to Resolved
Applied in changeset 3c2e213a81324ca518545d8fc8db8b2c7ca08e29.