From 70b52e890cb7f8f7a7a030e2e77e0da2fed76448 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 26 Mar 2026 16:57:50 +0100 Subject: [PATCH] [BUGFIX] container dependency for workspace add a dependency for container children to the container when publishing a child. This prevents publishing a container child without publishing the container. Fixes: #643 s. also https://review.typo3.org/c/Packages/TYPO3.CMS/+/92862 This works for TYPO3 v14 only --- .github/workflows/ci.yml | 8 +++-- Build/phpstan13.neon | 1 + Build/phpstan14.neon | 2 ++ .../IsReferenceConsideredForDependency.php | 33 +++++++++++++++++++ .../Datahandler/Workspace/ContainerTest.php | 21 ++++++++++++ ...PublishChildPublishAlsoParentContainer.csv | 8 +++++ ...hChildPublishAlsoParentContainerResult.csv | 8 +++++ 7 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 Classes/Listener/IsReferenceConsideredForDependency.php create mode 100644 Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainer.csv create mode 100644 Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainerResult.csv diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5997723b..a4895e54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,12 +38,16 @@ jobs: run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s unit - name: Functional Tests - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --do-not-fail-on-deprecation + run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --do-not-fail-on-deprecation --exclude-group v14-only if: matrix.TYPO3 == '13' + - name: Functional Tests 14.1 + run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --exclude-group v14-only + if: matrix.TYPO3 == '14' + - name: Functional Tests 14 run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional - if: matrix.TYPO3 != '13' + if: matrix.TYPO3 == '14-dev' - name: Acceptance Tests run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s acceptance -- --fail-fast diff --git a/Build/phpstan13.neon b/Build/phpstan13.neon index c07c5454..11670234 100644 --- a/Build/phpstan13.neon +++ b/Build/phpstan13.neon @@ -12,4 +12,5 @@ parameters: - %currentWorkingDirectory%/Classes/Listener/PageContentPreviewRendering.php - %currentWorkingDirectory%/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php - %currentWorkingDirectory%/Classes/Hooks/Datahandler/ContentElementRestriction + - %currentWorkingDirectory%/Classes/Listener/IsReferenceConsideredForDependency.php diff --git a/Build/phpstan14.neon b/Build/phpstan14.neon index f003d8c4..8bd189ab 100644 --- a/Build/phpstan14.neon +++ b/Build/phpstan14.neon @@ -12,4 +12,6 @@ parameters: - %currentWorkingDirectory%/Classes/Listener/LegacyPageContentPreviewRendering.php - %currentWorkingDirectory%/Classes/ContentDefender - %currentWorkingDirectory%/Tests/Functional/Integrity/IntegrityTest.php + # can be removed when 14.2 is released + - %currentWorkingDirectory%/Classes/Listener/IsReferenceConsideredForDependency.php diff --git a/Classes/Listener/IsReferenceConsideredForDependency.php b/Classes/Listener/IsReferenceConsideredForDependency.php new file mode 100644 index 00000000..c4dc475b --- /dev/null +++ b/Classes/Listener/IsReferenceConsideredForDependency.php @@ -0,0 +1,33 @@ +getTableName() === 'tt_content' && + $event->getFieldName() === 'tx_container_parent' && + $event->getReferenceTable() === 'tt_content' && + $event->getAction() === DependencyCollectionAction::Publish + ) { + $event->setDependency(true); + } + } +} diff --git a/Tests/Functional/Datahandler/Workspace/ContainerTest.php b/Tests/Functional/Datahandler/Workspace/ContainerTest.php index 3a48b484..70f11db9 100644 --- a/Tests/Functional/Datahandler/Workspace/ContainerTest.php +++ b/Tests/Functional/Datahandler/Workspace/ContainerTest.php @@ -13,6 +13,7 @@ */ use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\WorkspaceAspect; @@ -31,6 +32,26 @@ protected function setUp(): void $context->setAspect('workspace', $workspaceAspect); } + #[Test] + #[Group('v14-only')] + public function publishChildPublishAlsoParentContainer(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/PublishChildPublishAlsoParentContainer.csv'); + $cmdmap = [ + 'tt_content' => [ + 2 => [ + 'version' => [ + 'action' => 'publish', + 'swapWith' => 2, + ], + ], + ], + ]; + $this->dataHandler->start([], $cmdmap, $this->backendUser); + $this->dataHandler->process_cmdmap(); + self::assertCSVDataSet(__DIR__ . '/Fixtures/PublishChildPublishAlsoParentContainerResult.csv'); + } + #[Test] public function deleteContainerDeleteChildren(): void { diff --git a/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainer.csv b/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainer.csv new file mode 100644 index 00000000..6e6f53e6 --- /dev/null +++ b/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainer.csv @@ -0,0 +1,8 @@ +"tt_content" +,"uid","pid","CType","header","t3ver_wsid","t3ver_state","colPos","tx_container_parent" +,"1","1","b13-2cols-with-header-container","container-element","1","1","0","0" +,"2","1","header","container-child-element","1","1","200","1" +"sys_refindex" +,"hash","workspace","tablename","field","ref_table","ref_uid","recuid" +,"73cc8f1fe4a83716bd7bf9e2153dbc42","1","tt_content","tx_container_parent","tt_content","1","2" + diff --git a/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainerResult.csv b/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainerResult.csv new file mode 100644 index 00000000..a2131bcf --- /dev/null +++ b/Tests/Functional/Datahandler/Workspace/Fixtures/PublishChildPublishAlsoParentContainerResult.csv @@ -0,0 +1,8 @@ +"tt_content" +,"uid","pid","CType","header","t3ver_wsid","colPos","tx_container_parent" +,"1","1","b13-2cols-with-header-container","container-element","0","0","0" +,"2","1","header","container-child-element","0","200","1" +"sys_refindex" +,"hash","workspace","tablename","field","ref_table","ref_uid","recuid" +,"06066e3d1b5e88d04eb6a99178133874","0","tt_content","tx_container_parent","tt_content","1","2" +