Skip to content

Commit 70b52e8

Browse files
committed
[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
1 parent 8bbdbaf commit 70b52e8

7 files changed

Lines changed: 79 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ jobs:
3838
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s unit
3939

4040
- name: Functional Tests
41-
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --do-not-fail-on-deprecation
41+
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --do-not-fail-on-deprecation --exclude-group v14-only
4242
if: matrix.TYPO3 == '13'
4343

44+
- name: Functional Tests 14.1
45+
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional -- --exclude-group v14-only
46+
if: matrix.TYPO3 == '14'
47+
4448
- name: Functional Tests 14
4549
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional
46-
if: matrix.TYPO3 != '13'
50+
if: matrix.TYPO3 == '14-dev'
4751

4852
- name: Acceptance Tests
4953
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s acceptance -- --fail-fast

Build/phpstan13.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ parameters:
1212
- %currentWorkingDirectory%/Classes/Listener/PageContentPreviewRendering.php
1313
- %currentWorkingDirectory%/Classes/Listener/ManipulateBackendLayoutColPosConfigurationForPage.php
1414
- %currentWorkingDirectory%/Classes/Hooks/Datahandler/ContentElementRestriction
15+
- %currentWorkingDirectory%/Classes/Listener/IsReferenceConsideredForDependency.php
1516

Build/phpstan14.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ parameters:
1212
- %currentWorkingDirectory%/Classes/Listener/LegacyPageContentPreviewRendering.php
1313
- %currentWorkingDirectory%/Classes/ContentDefender
1414
- %currentWorkingDirectory%/Tests/Functional/Integrity/IntegrityTest.php
15+
# can be removed when 14.2 is released
16+
- %currentWorkingDirectory%/Classes/Listener/IsReferenceConsideredForDependency.php
1517

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace B13\Container\Listener;
6+
7+
/*
8+
* This file is part of TYPO3 CMS-based extension "container" by b13.
9+
*
10+
* It is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License, either version 2
12+
* of the License, or any later version.
13+
*/
14+
15+
use TYPO3\CMS\Core\Attribute\AsEventListener;
16+
use TYPO3\CMS\Workspaces\Dependency\DependencyCollectionAction;
17+
use TYPO3\CMS\Workspaces\Event\IsReferenceConsideredForDependencyEvent;
18+
19+
#[AsEventListener(identifier: 'tx-container-is-reference-considered-for-dependency')]
20+
class IsReferenceConsideredForDependency
21+
{
22+
public function __invoke(IsReferenceConsideredForDependencyEvent $event)
23+
{
24+
if (
25+
$event->getTableName() === 'tt_content' &&
26+
$event->getFieldName() === 'tx_container_parent' &&
27+
$event->getReferenceTable() === 'tt_content' &&
28+
$event->getAction() === DependencyCollectionAction::Publish
29+
) {
30+
$event->setDependency(true);
31+
}
32+
}
33+
}

Tests/Functional/Datahandler/Workspace/ContainerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler;
16+
use PHPUnit\Framework\Attributes\Group;
1617
use PHPUnit\Framework\Attributes\Test;
1718
use TYPO3\CMS\Core\Context\Context;
1819
use TYPO3\CMS\Core\Context\WorkspaceAspect;
@@ -31,6 +32,26 @@ protected function setUp(): void
3132
$context->setAspect('workspace', $workspaceAspect);
3233
}
3334

35+
#[Test]
36+
#[Group('v14-only')]
37+
public function publishChildPublishAlsoParentContainer(): void
38+
{
39+
$this->importCSVDataSet(__DIR__ . '/Fixtures/PublishChildPublishAlsoParentContainer.csv');
40+
$cmdmap = [
41+
'tt_content' => [
42+
2 => [
43+
'version' => [
44+
'action' => 'publish',
45+
'swapWith' => 2,
46+
],
47+
],
48+
],
49+
];
50+
$this->dataHandler->start([], $cmdmap, $this->backendUser);
51+
$this->dataHandler->process_cmdmap();
52+
self::assertCSVDataSet(__DIR__ . '/Fixtures/PublishChildPublishAlsoParentContainerResult.csv');
53+
}
54+
3455
#[Test]
3556
public function deleteContainerDeleteChildren(): void
3657
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"tt_content"
2+
,"uid","pid","CType","header","t3ver_wsid","t3ver_state","colPos","tx_container_parent"
3+
,"1","1","b13-2cols-with-header-container","container-element","1","1","0","0"
4+
,"2","1","header","container-child-element","1","1","200","1"
5+
"sys_refindex"
6+
,"hash","workspace","tablename","field","ref_table","ref_uid","recuid"
7+
,"73cc8f1fe4a83716bd7bf9e2153dbc42","1","tt_content","tx_container_parent","tt_content","1","2"
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"tt_content"
2+
,"uid","pid","CType","header","t3ver_wsid","colPos","tx_container_parent"
3+
,"1","1","b13-2cols-with-header-container","container-element","0","0","0"
4+
,"2","1","header","container-child-element","0","200","1"
5+
"sys_refindex"
6+
,"hash","workspace","tablename","field","ref_table","ref_uid","recuid"
7+
,"06066e3d1b5e88d04eb6a99178133874","0","tt_content","tx_container_parent","tt_content","1","2"
8+

0 commit comments

Comments
 (0)