diff --git a/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php b/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php index 6d16a96f..62a54893 100644 --- a/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php +++ b/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php @@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression; use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; use TYPO3\CMS\Core\Database\Query\QueryBuilder; +use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer; use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -341,6 +342,9 @@ class Typo3DbQueryParser /** @var ColumnMap $columnMap */ $relationTableName = (string)$columnMap->getRelationTableName(); $queryBuilderForSubselect = $this->queryBuilder->getConnection()->createQueryBuilder(); + if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { + $queryBuilderForSubselect->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); + } $queryBuilderForSubselect ->select($columnMap->getParentKeyFieldName()) ->from($relationTableName) @@ -368,6 +372,9 @@ class Typo3DbQueryParser // Build the SQL statement of the subselect $queryBuilderForSubselect = $this->queryBuilder->getConnection()->createQueryBuilder(); + if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { + $queryBuilderForSubselect->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); + } $queryBuilderForSubselect ->select($parentKeyFieldName) ->from($childTableName) @@ -789,6 +796,9 @@ class Typo3DbQueryParser $defLangTableAlias = $tableAlias . '_dl'; $defaultLanguageRecordsSubSelect = $this->queryBuilder->getConnection()->createQueryBuilder(); + if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { + $defaultLanguageRecordsSubSelect->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); + } $defaultLanguageRecordsSubSelect ->select($defLangTableAlias . '.uid') ->from($tableName, $defLangTableAlias) @@ -826,6 +836,9 @@ class Typo3DbQueryParser // together with not translated default language records $translatedOnlyTableAlias = $tableAlias . '_to'; $queryBuilderForSubselect = $this->queryBuilder->getConnection()->createQueryBuilder(); + if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { + $queryBuilderForSubselect->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); + } $queryBuilderForSubselect ->select($translatedOnlyTableAlias . '.' . $transOrigPointerField) ->from($tableName, $translatedOnlyTableAlias)