From 41cb6f3274985e8fab088b3407cd9ab502d1f36c Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Wed, 16 May 2012 15:11:52 +0200 Subject: [PATCH] [BUGFIX] Missing column in t3lib_TCEmain::getPreviousLocalizedRecordUid Patch from issue #35260 is faulty as its breaks getPreviousLocalizedRecordUid when using tt_content Correct localization of tt_content IRRE elements. This patch fixes following problems: * reusing $sortRow as select statement is just bad practice * using a combination like "sorting,colSort" as an index for $row wont work * the current implementation creates SQL like ' AND sorting,colPos<0 AND ' which wont work. Fixes: #35260 (follow up), #37221 Releases: 4.7, 4.6, 4.5 --- t3lib/class.t3lib_tcemain.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/t3lib/class.t3lib_tcemain.php b/t3lib/class.t3lib_tcemain.php index 7fd3764..d73600a 100644 --- a/t3lib/class.t3lib_tcemain.php +++ b/t3lib/class.t3lib_tcemain.php @@ -5917,21 +5917,22 @@ class t3lib_TCEmain { $previousLocalizedRecordUid = $uid; if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['sortby']) { $sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby']; + $select = $sortRow . ',pid,uid'; // For content elements, we also need the colPos if ($table === 'tt_content') { - $sortRow .= ',colPos'; + $select .= ',colPos'; } // Get the sort value of the default language record - $row = t3lib_BEfunc::getRecord($table, $uid, $sortRow . ',pid,uid'); + $row = t3lib_BEfunc::getRecord($table, $uid, $select); if (is_array($row)) { // Find the previous record in default language on the same page $where = 'pid=' . intval($pid) . ' AND ' . 'sys_language_uid=0' . ' AND ' . $sortRow . '<' . intval($row[$sortRow]); // Respect the colPos for content elements if ($table === 'tt_content') { - $where .= ' AND colPos=' . $row['colPos']; + $where .= ' AND colPos=' . intval($row['colPos']); } - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($sortRow . ',pid,uid', $table, $where . $this->deleteClause($table), '', $sortRow . ' DESC', '1'); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where . $this->deleteClause($table), '', $sortRow . ' DESC', '1'); // If there is an element, find its localized record in specified localization language if ($previousRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $previousLocalizedRecord = t3lib_BEfunc::getRecordLocalization($table, $previousRow['uid'], $language); -- 1.7.10.msysgit.1