Commit 4b54d29c 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/+/72417

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent a9a957e9
Pipeline #20375 passed with stages
in 43 minutes and 14 seconds
...@@ -187,6 +187,7 @@ class RootlineUtility ...@@ -187,6 +187,7 @@ class RootlineUtility
$mountPointParameter, $mountPointParameter,
$this->languageUid, $this->languageUid,
$this->workspaceUid, $this->workspaceUid,
$this->context->getAspect('visibility')->includeHiddenContent() ? '1' : '0',
]); ]);
} }
...@@ -288,6 +289,12 @@ class RootlineUtility ...@@ -288,6 +289,12 @@ class RootlineUtility
$relatedUids = []; $relatedUids = [];
if (($fieldConfig['MM'] ?? false) || (!empty($fieldConfig['foreign_table'] ?? $fieldConfig['allowed'] ?? ''))) { if (($fieldConfig['MM'] ?? false) || (!empty($fieldConfig['foreign_table'] ?? $fieldConfig['allowed'] ?? ''))) {
$relationHandler = GeneralUtility::makeInstance(RelationHandler::class); $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->setWorkspaceId($this->workspaceUid);
$relationHandler->start( $relationHandler->start(
$pageRecord[$column], $pageRecord[$column],
......
...@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend; ...@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\LanguageAspect; use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Context\WorkspaceAspect; use TYPO3\CMS\Core\Context\WorkspaceAspect;
use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
...@@ -314,15 +315,16 @@ class RootlineUtilityTest extends UnitTestCase ...@@ -314,15 +315,16 @@ class RootlineUtilityTest extends UnitTestCase
$context = new Context(); $context = new Context();
$context->setAspect('workspace', new WorkspaceAspect(15)); $context->setAspect('workspace', new WorkspaceAspect(15));
$context->setAspect('visibility', new VisibilityAspect());
$context->setAspect('language', new LanguageAspect(8, 8, LanguageAspect::OVERLAYS_OFF)); $context->setAspect('language', new LanguageAspect(8, 8, LanguageAspect::OVERLAYS_OFF));
$this->subject->__construct(42, '47-11', $context); $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); $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)); $context->setAspect('workspace', new WorkspaceAspect(0));
$this->subject->__construct(42, '47-11', $context); $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