[BUGFIX] Date of 1970-01-01 is shown in unset date fields
authorBenjamin Mack <benni@typo3.org>
Thu, 7 Jul 2011 09:34:43 +0000 (11:34 +0200)
committerSteffen Gebert <steffen.gebert@typo3.org>
Thu, 7 Jul 2011 19:53:58 +0000 (21:53 +0200)
The backend shows 1970-01-01 since TYPO3 4.3, even though this
value is empty. I know that there is a problem with mySQL that
cannot differentiate between "0" and NULL, and that this is a
more difficult problem. In any case, even though showing
1970-01-01 is "valid", this is just a bad thing in terms of
usability and user-friendly-ness.

Change-Id: I780cd5e500378c06ddc680db6015a124b66820ca
Resolves: #27936
Releases: 4.6, 4.5, 4.4, 4.3
Reviewed-on: http://review.typo3.org/3098
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert
t3lib/class.t3lib_befunc.php

index 6470e0d..e5c7ac2 100644 (file)
@@ -2228,13 +2228,18 @@ final class t3lib_BEfunc {
                                        }
                                        break;
                                case 'input':
-                                       if (isset($value)) {
+                                               // currently, this feature does not show "0" or the date
+                                               // "1970-01-01", but this is a DB limitation, as we cannot
+                                               // differentiate between "0" and "NULL" in the DB
+                                               // however, this solution is the most "user-friendly" for
+                                               // 99.9% percent of all use-cases.
+                                       if (!empty($value)) {
                                                if (t3lib_div::inList($theColConf['eval'], 'date')) {
                                                        $l = self::date($value) .
-                                                                       ' (' .
-                                                                       ($GLOBALS['EXEC_TIME'] - $value > 0 ? '-' : '') .
-                                                                       self::calcAge(abs($GLOBALS['EXEC_TIME'] - $value), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')) .
-                                                                       ')';
+                                                               ' (' .
+                                                               ($GLOBALS['EXEC_TIME'] - $value > 0 ? '-' : '') .
+                                                               self::calcAge(abs($GLOBALS['EXEC_TIME'] - $value), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')) .
+                                                               ')';
                                                } elseif (t3lib_div::inList($theColConf['eval'], 'time')) {
                                                        $l = self::time($value, FALSE);
                                                } elseif (t3lib_div::inList($theColConf['eval'], 'timesec')) {