Project

General

Profile

Bug #88739 » frontend-link-translated-access-restricted2.diff

Alexander Stehlik, 2019-10-23 20:32

View differences:

Classes/ContentObject/Menu/AbstractMenuContentObject.php
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
use TYPO3\CMS\Core\Database\RelationHandler;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Site\Entity\Site;
......
$skippedEnableFields = [];
if (!empty($this->mconf['showAccessRestrictedPages'])) {
$skippedEnableFields = ['fe_group' => 1];
$restrictions = GeneralUtility::makeInstance(FrontendRestrictionContainer::class);
$restrictions->removeByType(FrontendGroupRestriction::class);
$this->sys_page->setLanguageOverlayRestrictions($restrictions);
}
/** @var RelationHandler $loadDB*/
$loadDB = GeneralUtility::makeInstance(RelationHandler::class);
......
$menuItems[] = $this->sys_page->getPageOverlay($row);
}
}
$this->sys_page->setLanguageOverlayRestrictions(null);
return $menuItems;
}
Classes/Page/PageRepository.php
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendWorkspaceRestriction;
......
*/
protected $context;
/**
* @var AbstractRestrictionContainer|null
*/
protected $languageOverlayRestrictions = null;
/**
* PageRepository constructor to set the base context, this will effectively remove the necessity for
* setting properties from the outside.
......
}
}
public function setLanguageOverlayRestrictions(?AbstractRestrictionContainer $languageOverlayRestrictions): void
{
$this->languageOverlayRestrictions = $languageOverlayRestrictions;
}
/**
* init() MUST be run directly after creating a new template-object
* This sets the internal variable $this->where_hid_del to the correct where
......
$languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
$overlays = [];
$restrictionsContainer = $this->languageOverlayRestrictions;
if (!$restrictionsContainer) {
$restrictionsContainer = GeneralUtility::makeInstance(FrontendRestrictionContainer::class);
}
foreach ($pageUids as $pageId) {
// Create a map based on the order of values in $languageUids. Those entries reflect the order of the language + fallback chain.
// We can't work with database ordering since there is no common SQL clause to order by e.g. [7, 1, 2].
$orderedListByLanguages = array_flip($languageUids);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
$queryBuilder->setRestrictions($restrictionsContainer);
$result = $queryBuilder->select('*')
->from('pages')
->where(
(10-10/10)