diff --git a/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php b/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php index 3e630561..710283fa 100644 --- a/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php +++ b/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php @@ -15,7 +15,6 @@ use B13\Container\Domain\Factory\Exception; use B13\Container\Domain\Factory\PageView\Backend\ContainerFactory; use B13\Container\Tca\Registry; -use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\Event\ManipulateBackendLayoutColPosConfigurationForPageEvent; use TYPO3\CMS\Core\Attribute\AsEventListener; @@ -29,7 +28,7 @@ public function __construct(protected ContainerFactory $containerFactory, protec public function __invoke(ManipulateBackendLayoutColPosConfigurationForPageEvent $e) { - $parent = $this->getParentUid($e->request); + $parent = $this->getParentUid($e); if ($parent === null) { return; } @@ -48,8 +47,9 @@ public function __invoke(ManipulateBackendLayoutColPosConfigurationForPageEvent ]; } - private function getParentUid(?ServerRequestInterface $request): ?int + private function getParentUid(ManipulateBackendLayoutColPosConfigurationForPageEvent $e): ?int { + $request = $e->request; if ($request === null) { return null; } @@ -74,8 +74,8 @@ private function getParentUid(?ServerRequestInterface $request): ?int } $recordUid = abs((int)$recordUid); // TcaCTypeItems: edit record - $record = BackendUtility::getRecord('tt_content', $recordUid, 'tx_container_parent'); - if (isset($record['tx_container_parent'])) { + $record = BackendUtility::getRecord('tt_content', $recordUid, 'tx_container_parent,colPos'); + if (isset($record['tx_container_parent']) && (int)$record['colPos'] === $e->colPos) { return (int)$record['tx_container_parent']; } } diff --git a/Tests/Functional/Listener/ManipulateBackendLayoutColPosConfigurationForPageTest.php b/Tests/Functional/Listener/ManipulateBackendLayoutColPosConfigurationForPageTest.php index 34d2771b..23753bff 100644 --- a/Tests/Functional/Listener/ManipulateBackendLayoutColPosConfigurationForPageTest.php +++ b/Tests/Functional/Listener/ManipulateBackendLayoutColPosConfigurationForPageTest.php @@ -71,4 +71,20 @@ public function editContainerChildElement(): void $listener($e); self::assertSame(['allowedContentTypes' => 'header, textmedia, b13-2cols', 'disallowedContentTypes' => ''], $e->configuration); } + + #[Test] + public function editContainerChildElementWithWrongColPos(): void + { + // https://forge.typo3.org/issues/110106 + if ((new Typo3Version())->getMajorVersion() < 14) { + self::markTestSkipped('only v14'); + } + $this->importCSVDataSet(__DIR__ . '/Fixtures/ManipulateBackendLayoutColPosConfigurationForPageTest.csv'); + $request = new ServerRequest(); + $request = $request->withQueryParams(['edit' => ['tt_content' => [1 => 'edit']]]); + $e = new ManipulateBackendLayoutColPosConfigurationForPageEvent([], new BackendLayout('foo', 'bar', []), 0, 1, $request); + $listener = $this->getContainer()->get(ManipulateBackendLayoutColPosConfigurationForPage::class); + $listener($e); + self::assertSame([], $e->configuration); + } }