[BUGFIX] Use proper fieldname to check result in getFirstTimeValueForRecord() 88/43488/3
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 23 Sep 2015 04:49:52 +0000 (06:49 +0200)
committerNicole Cordes <typo3@cordes.co>
Wed, 23 Sep 2015 19:48:56 +0000 (21:48 +0200)
The method builds a query using "as". Therefore the result needs to be checked
by using the same name.

Change-Id: Idba29d7cc1c962899aacbe239bde1be632995ddd
Resolves: #69875
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/43488
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index deb8c55..6baa84e 100644 (file)
@@ -4606,15 +4606,14 @@ class TypoScriptFrontendController {
                $enableFields = $this->sys_page->enableFields($tableName, $showHidden, array('starttime' => TRUE, 'endtime' => TRUE));
                // For each start or end time field, get the minimum value
                foreach (array('starttime', 'endtime') as $field) {
-                       // Note: there is no need to load TCA because we need only enable columns!
                        if (isset($GLOBALS['TCA'][$tableName]['ctrl']['enablecolumns'][$field])) {
                                $timeField = $GLOBALS['TCA'][$tableName]['ctrl']['enablecolumns'][$field];
                                $selectField = 'MIN(' . $timeField . ') AS ' . $field;
                                $whereCondition = $timeField . ' > ' . $now;
                                // Find the smallest timestamp which could influence the cache duration (but is larger than 0)
                                $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow($selectField, $tableName, 'pid = ' . (int)$pid . ' AND ' . $whereCondition . $enableFields);
-                               if ($row && !is_null($row[$timeField])) {
-                                       $result = min($result, $row[$timeField]);
+                               if ($row && !is_null($row[$field])) {
+                                       $result = min($result, $row[$field]);
                                }
                        }
                }