[BUGFIX] Value 0 in integer fields is not shown in List module anymore
authorSteffen Gebert <steffen.gebert@typo3.org>
Fri, 15 Jul 2011 17:40:23 +0000 (19:40 +0200)
committerBenjamin Mack <benni@typo3.org>
Sun, 17 Jul 2011 11:09:01 +0000 (13:09 +0200)
A side-effect of #27936 is that the value 0 of integer fields is not
shown anymore in the List module. This error was also catched by the
failing Unit Test t3lib_befuncTest::getProcessedValueForZeroStringIsZero

Change-Id: I07da5d05c08a9066e8e9c8ad68d3f83ef6f7dbcb
Resolves: #28218
Relates: #27936
Releases: 4.6, 4.5, 4.4, 4.3
Reviewed-on: http://review.typo3.org/3369
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
t3lib/class.t3lib_befunc.php

index d487190..b5105e1 100644 (file)
@@ -2096,24 +2096,28 @@ final class t3lib_BEfunc {
                                        }
                                        break;
                                case 'input':
-                                               // 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)) {
+                                               // hide value 0 for dates, but show it for everything else
+                                       if (isset($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')) .
-                                                               ')';
+                                                       if (!empty($value)) {
+                                                               $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')) .
+                                                                       ')';
+                                                       }
                                                } elseif (t3lib_div::inList($theColConf['eval'], 'time')) {
-                                                       $l = self::time($value, FALSE);
+                                                       if (!empty($value)) {
+                                                               $l = self::time($value, FALSE);
+                                                       }
                                                } elseif (t3lib_div::inList($theColConf['eval'], 'timesec')) {
-                                                       $l = self::time($value);
+                                                       if (!empty($value)) {
+                                                               $l = self::time($value);
+                                                       }
                                                } elseif (t3lib_div::inList($theColConf['eval'], 'datetime')) {
-                                                       $l = self::datetime($value);
+                                                       if (!empty($value)) {
+                                                               $l = self::datetime($value);
+                                                       }
                                                } else {
                                                        $l = $value;
                                                }