Commit 8583e6ac authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Ensure hidden records are filtered out in RootlineUtility

RelationHandler always returns hidden records as well,
but they will crash when having pages.media with hidden
records.

If running in Frontend, this should not be allowed,
so the hidden restriction comes into effect.

This happens because we now use the RelationHandler
consistently instead of using manual SQL queries since
11.5.3.

Resolves: #95997
Resolves: #82844
Related: #63353
Releases: main, 11.5
Change-Id: I78131ebed97a20276adbe51fbc77dacfab2a0e77
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72273


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 26507892
......@@ -187,6 +187,7 @@ class RootlineUtility
$mountPointParameter,
$this->languageUid,
$this->workspaceUid,
$this->context->getAspect('visibility')->includeHiddenContent() ? '1' : '0',
]);
}
......@@ -288,6 +289,12 @@ class RootlineUtility
$relatedUids = [];
if (($fieldConfig['MM'] ?? false) || (!empty($fieldConfig['foreign_table'] ?? $fieldConfig['allowed'] ?? ''))) {
$relationHandler = GeneralUtility::makeInstance(RelationHandler::class);
// do not include hidden relational fields
$relationalTable = $fieldConfig['foreign_table'] ?? $fieldConfig['allowed'];
$hiddenFieldName = $GLOBALS['TCA'][$relationalTable]['ctrl']['enablecolumns']['disabled'] ?? null;
if (!$this->context->getAspect('visibility')->includeHiddenContent() && $hiddenFieldName) {
$fieldConfig['foreign_match_fields'][$hiddenFieldName] = 0;
}
$relationHandler->setWorkspaceId($this->workspaceUid);
$relationHandler->start(
$pageRecord[$column],
......
......@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Context\WorkspaceAspect;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -314,15 +315,16 @@ class RootlineUtilityTest extends UnitTestCase
$context = new Context();
$context->setAspect('workspace', new WorkspaceAspect(15));
$context->setAspect('visibility', new VisibilityAspect());
$context->setAspect('language', new LanguageAspect(8, 8, LanguageAspect::OVERLAYS_OFF));
$this->subject->__construct(42, '47-11', $context);
self::assertSame('42_47-11_8_15', $this->subject->getCacheIdentifier());
self::assertSame('42_47-11_8_15_0', $this->subject->getCacheIdentifier());
$this->subject->__construct(42, '47-11', $context);
self::assertSame('42_47-11_8_15', $this->subject->getCacheIdentifier());
self::assertSame('42_47-11_8_15_0', $this->subject->getCacheIdentifier());
$context->setAspect('workspace', new WorkspaceAspect(0));
$this->subject->__construct(42, '47-11', $context);
self::assertSame('42_47-11_8_0', $this->subject->getCacheIdentifier());
self::assertSame('42_47-11_8_0_0', $this->subject->getCacheIdentifier());
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment