[BUGFIX] RootlineUtility uses backticks which leads to crashing dbal
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Utility / RootlineUtility.php
index fa54d18..ff55f49 100644 (file)
@@ -27,8 +27,6 @@ namespace TYPO3\CMS\Core\Utility;
  * A utility resolving and Caching the Rootline generation
  *
  * @author Steffen Ritter <steffen.ritter@typo3.org>
- * @package TYPO3
- * @subpackage t3lib
  */
 class RootlineUtility {
 
@@ -215,8 +213,8 @@ class RootlineUtility {
                        $this->pageContext->versionOL('pages', $row, FALSE, TRUE);
                        $this->pageContext->fixVersioningPid('pages', $row);
                        if (is_array($row)) {
-                               $row = $this->enrichWithRelationFields($uid, $row);
                                $this->pageContext->getPageOverlay($row, $this->languageUid);
+                               $row = $this->enrichWithRelationFields($uid, $row);
                                self::$pageRecordCache[$this->getCacheIdentifier($uid)] = $row;
                        }
                }
@@ -246,16 +244,21 @@ class RootlineUtility {
                                } elseif ($configuration['foreign_field']) {
                                        $table = $configuration['foreign_table'];
                                        $field = $configuration['foreign_field'];
-                                       $whereClauseParts = array('`' . $field . '` = ' . intval($uid));
+                                       $whereClauseParts = array($field . ' = ' . intval($uid));
                                        if (isset($configuration['foreign_match_fields']) && is_array($configuration['foreign_match_fields'])) {
                                                foreach ($configuration['foreign_match_fields'] as $field => $value) {
-                                                       $whereClauseParts[] = '`' . $field . '` = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table);
+                                                       $whereClauseParts[] = $field . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $table);
                                                }
                                        }
                                        if (isset($configuration['foreign_table_field'])) {
-                                               $whereClauseParts[] = '`' . trim($configuration['foreign_table_field']) . '` = \'pages\'';
+                                               if (intval($pageRecord['sys_language_uid']) > 0) {
+                                                       $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages_language_overlay\'';
+                                               } else {
+                                                       $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages\'';
+                                               }
                                        }
                                        $whereClause = implode(' AND ', $whereClauseParts);
+                                       $whereClause .= $this->pageContext->deleteClause($table);
                                        $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, $whereClause);
                                        if (!is_array($rows)) {
                                                throw new \RuntimeException('Could to resolve related records for page ' . $uid . ' and foreign_table ' . htmlspecialchars($configuration['foreign_table']), 1343589452);