Skip to content

Commit 251950e

Browse files
committed
[BUGFIX] DataHandler can modify soft-deleted records
This slipped through with #106382: DataHandler fetches records again in process_datamap() even if they are soft-deleted to allow modification of such records. An ext:content_defender functional test found this change in behavior. The patch fixes this again adds tests. Resolves: #106505 Related: #106382 Releases: main, 13.4 Change-Id: I14d48dba6d9d352ec8c2a52f5c21fa7ef2876df5 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/88934 Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Stefan Bürk <stefan@buerk.tech>
1 parent 0f3f951 commit 251950e

File tree

12 files changed

+212
-1
lines changed

12 files changed

+212
-1
lines changed

typo3/sysext/core/Classes/DataHandling/DataHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ public function process_datamap(): void
861861
$id = (int)$id;
862862
$fieldArray = [];
863863
$recordAccess = null;
864-
$currentRecord = BackendUtility::getRecord($table, $id);
864+
$currentRecord = BackendUtility::getRecord($table, $id, '*', '', false);
865865
if (empty($currentRecord) || ($currentRecord['pid'] ?? null) === null) {
866866
// Skip if there is no record. Skip if record has no pid column indicating incomplete DB.
867867
continue;

typo3/sysext/core/Tests/Functional/DataScenarios/Regular/AbstractActionTestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ public function modifyContent(): void
8686
$this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
8787
}
8888

89+
public function modifySoftDeletedContent(): void
90+
{
91+
$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
92+
$this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdSecond, ['header' => 'Testing #1']);
93+
}
94+
8995
public function modifyTranslatedContent(): void
9096
{
9197
$this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdThirdLocalized, ['header' => 'Testing Translation #3']);

typo3/sysext/core/Tests/Functional/DataScenarios/Regular/Modify/ActionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public function modifyContent(): void
7676
->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
7777
}
7878

79+
#[Test]
80+
public function modifySoftDeletedContent(): void
81+
{
82+
parent::modifySoftDeletedContent();
83+
$this->assertCSVDataSet(__DIR__ . '/DataSet/modifySoftDeletedContent.csv');
84+
}
85+
7986
#[Test]
8087
public function modifyTranslatedContent(): void
8188
{
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"pages",,,,,,,,,,,,,
2+
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug"
3+
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest","/"
4+
,50,0,512,0,0,0,0,0,0,0,"Second Root Page","/"
5+
,51,50,128,0,0,0,0,0,0,0,"DataHandlerTest in second tree","/data-handler"
6+
,52,51,128,0,0,0,0,0,0,0,"Relations in second tree","/data-handler/relations"
7+
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler"
8+
,89,88,256,0,0,0,0,0,0,0,"Relations","/data-handler/relations"
9+
,90,88,512,0,0,0,0,0,0,0,"Target","/data-handler/target"
10+
,91,88,256,0,1,89,0,0,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations"
11+
,92,88,256,0,2,89,0,0,0,0,"[Translate to Deutsch:] Relations","/data-handler/translate-to-deutsch-relations"
12+
"tt_content",,,,,,,,,,,,,
13+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header"
14+
,200,88,256,0,0,0,0,0,0,0,0,"Regular Element #0"
15+
,201,88,512,0,-1,0,0,0,0,0,0,"Language all element"
16+
,297,89,384,0,0,0,0,0,0,0,0,"Regular Element #1"
17+
,298,89,512,1,0,0,0,0,0,0,0,"Testing #1"
18+
,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3"
19+
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3"
20+
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1"
21+
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1"
22+
"sys_refindex"
23+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
24+
,"02aa95a647ed365ffeeac881bd1af449","pages",91,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
25+
,"14f90231b8565c61decd2aeaebea6034","pages",92,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
26+
,"ca4f164be617724388f00923729e8558","tt_content",300,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",299,,0,0,2147483647,0,0,
27+
,"3676712de719382fe386617c1942c940","tt_content",301,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,
28+
,"2b5621b6ac407f06a71e517bf98c9c94","tt_content",302,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,

typo3/sysext/core/Tests/Functional/DataScenarios/Regular/WorkspacesDiscard/ActionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public function modifyContent(): void
7575
$this->assertCSVDataSet(__DIR__ . '/DataSet/modifyContent.csv');
7676
}
7777

78+
#[Test]
79+
public function modifySoftDeletedContent(): void
80+
{
81+
parent::modifySoftDeletedContent();
82+
$this->actionService->clearWorkspaceRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
83+
$this->assertCSVDataSet(__DIR__ . '/DataSet/modifySoftDeletedContent.csv');
84+
}
85+
7886
#[Test]
7987
public function hideContent(): void
8088
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"pages",,,,,,,,,,,,,,,,,
2+
,"uid","pid","sorting","hidden","deleted","sys_language_uid","l10n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug",,,,,
3+
,1,0,256,0,0,0,0,0,0,0,0,"FunctionalTest","/",,,,,
4+
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,,
5+
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,,
6+
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,,
7+
,91,88,256,0,0,1,89,0,0,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,,
8+
,92,88,256,0,0,2,89,0,0,0,0,"[Translate to Deutsch:] Relations","/data-handler/translate-to-deutsch-relations",,,,,
9+
"sys_workspace",,,,,,,,,,,,,,,,,
10+
,"uid","pid","deleted","title","adminusers","members","db_mountpoints","file_mountpoints","freeze","live_edit","publish_access","custom_stages","stagechg_notification","edit_notification_defaults","edit_allow_notificaton_settings","publish_notification_defaults","publish_allow_notificaton_settings"
11+
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
12+
,2,0,0,"Workspace #2",,,,,0,0,0,0,0,0,0,0,0
13+
"sys_workspace_stage",,,,,,,,,,,,,,,,,
14+
,"uid","pid","tstamp","deleted","sorting","title","responsible_persons","default_mailcomment","parentid","notification_defaults","allow_notificaton_settings",,,,,
15+
,1,0,1290048921,0,1,"Stage 1","be_users_3",,1,0,0,,,,,
16+
"tt_content",,,,,,,,,,,,,,,,,
17+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header",,,,
18+
,200,88,256,0,0,0,0,0,0,0,0,"Regular Element #0"
19+
,201,88,512,0,-1,0,0,0,0,0,0,"Language all element"
20+
,297,89,384,0,0,0,0,0,0,0,0,"Regular Element #1",,,,
21+
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,,,
22+
,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3",,,,
23+
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",,,,
24+
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",,,,
25+
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",,,,
26+
,320,89,512,0,0,0,0,2,2,0,298,"Regular Element #2",,,,
27+
"sys_refindex"
28+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
29+
,"02aa95a647ed365ffeeac881bd1af449","pages",91,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
30+
,"14f90231b8565c61decd2aeaebea6034","pages",92,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
31+
,"6f85cfacfff942817392efe26ff1ade0","sys_workspace",1,"custom_stages",0,0,2147483647,0,,,,0,0,"sys_workspace_stage",1,,0,0,2147483647,0,0,
32+
,"96a6b7ec63daee0e0ce5d4908b6eda6f","sys_workspace_stage",1,"responsible_persons",0,0,2147483647,0,,,,0,0,"be_users",3,,0,0,2147483647,0,0,
33+
,"ca4f164be617724388f00923729e8558","tt_content",300,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",299,,0,0,2147483647,0,0,
34+
,"3676712de719382fe386617c1942c940","tt_content",301,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,
35+
,"2b5621b6ac407f06a71e517bf98c9c94","tt_content",302,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,

typo3/sysext/core/Tests/Functional/DataScenarios/Regular/WorkspacesModify/ActionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ public function modifyContent(): void
9898
->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
9999
}
100100

101+
#[Test]
102+
public function modifySoftDeletedContent(): void
103+
{
104+
parent::modifySoftDeletedContent();
105+
$this->assertCSVDataSet(__DIR__ . '/DataSet/modifySoftDeletedContent.csv');
106+
}
107+
101108
#[Test]
102109
public function hideContent(): void
103110
{
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"pages",,,,,,,,,,,,,,,,,
2+
,"uid","pid","sorting","hidden","deleted","sys_language_uid","l10n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug",,,,
3+
,1,0,256,0,0,0,0,0,0,0,0,"FunctionalTest","/",,,,
4+
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,
5+
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,
6+
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,
7+
,91,88,256,0,0,1,89,0,0,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,
8+
,92,88,256,0,0,2,89,0,0,0,0,"[Translate to Deutsch:] Relations","/data-handler/translate-to-deutsch-relations",,,,
9+
"sys_workspace",,,,,,,,,,,,,,,,,
10+
,"uid","pid","deleted","title","adminusers","members","db_mountpoints","file_mountpoints","freeze","live_edit","publish_access","custom_stages","stagechg_notification","edit_notification_defaults","edit_allow_notificaton_settings","publish_notification_defaults","publish_allow_notificaton_settings"
11+
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
12+
,2,0,0,"Workspace #2",,,,,0,0,0,0,0,0,0,0,0
13+
"sys_workspace_stage",,,,,,,,,,,,,,,,,
14+
,"uid","pid","tstamp","deleted","sorting","title","responsible_persons","default_mailcomment","parentid","notification_defaults","allow_notificaton_settings",,,,,
15+
,1,0,1290048921,0,1,"Stage 1","be_users_3",,1,0,0,,,,,
16+
"tt_content",,,,,,,,,,,,,,,,,
17+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header",,,,
18+
,200,88,256,0,0,0,0,0,0,0,0,"Regular Element #0"
19+
,201,88,512,0,-1,0,0,0,0,0,0,"Language all element"
20+
,297,89,384,0,0,0,0,0,0,0,0,"Regular Element #1",,,,
21+
,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,,,
22+
,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3",,,,
23+
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",,,,
24+
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",,,,
25+
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",,,,
26+
,320,89,512,0,0,0,0,2,2,0,298,"Regular Element #2",,,,
27+
,321,89,512,0,0,0,0,1,2,0,298,"Testing #1",,,,
28+
"sys_refindex"
29+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
30+
,"02aa95a647ed365ffeeac881bd1af449","pages",91,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
31+
,"14f90231b8565c61decd2aeaebea6034","pages",92,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
32+
,"6f85cfacfff942817392efe26ff1ade0","sys_workspace",1,"custom_stages",0,0,2147483647,0,,,,0,0,"sys_workspace_stage",1,,0,0,2147483647,0,0,
33+
,"96a6b7ec63daee0e0ce5d4908b6eda6f","sys_workspace_stage",1,"responsible_persons",0,0,2147483647,0,,,,0,0,"be_users",3,,0,0,2147483647,0,0,
34+
,"ca4f164be617724388f00923729e8558","tt_content",300,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",299,,0,0,2147483647,0,0,
35+
,"3676712de719382fe386617c1942c940","tt_content",301,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,
36+
,"2b5621b6ac407f06a71e517bf98c9c94","tt_content",302,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,

typo3/sysext/core/Tests/Functional/DataScenarios/Regular/WorkspacesPublish/ActionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ public function modifyContent(): void
8282
->setTable(self::TABLE_Content)->setField('header')->setValues('Testing #1'));
8383
}
8484

85+
#[Test]
86+
public function modifySoftDeletedContent(): void
87+
{
88+
parent::modifySoftDeletedContent();
89+
$this->actionService->publishRecord(self::TABLE_Content, self::VALUE_ContentIdSecond);
90+
$this->assertCSVDataSet(__DIR__ . '/DataSet/modifySoftDeletedContent.csv');
91+
}
92+
8593
#[Test]
8694
public function hideContent(): void
8795
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"pages",,,,,,,,,,,,,,,,,
2+
,"uid","pid","sorting","hidden","deleted","sys_language_uid","l10n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","slug",,,,,
3+
,1,0,256,0,0,0,0,0,0,0,0,"FunctionalTest","/",,,,,
4+
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,,
5+
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,,
6+
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,,
7+
,91,88,256,0,0,1,89,0,0,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,,
8+
,92,88,256,0,0,2,89,0,0,0,0,"[Translate to Deutsch:] Relations","/data-handler/translate-to-deutsch-relations",,,,,
9+
"sys_workspace",,,,,,,,,,,,,,,,,
10+
,"uid","pid","deleted","title","adminusers","members","db_mountpoints","file_mountpoints","freeze","live_edit","publish_access","custom_stages","stagechg_notification","edit_notification_defaults","edit_allow_notificaton_settings","publish_notification_defaults","publish_allow_notificaton_settings"
11+
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
12+
,2,0,0,"Workspace #2",,,,,0,0,0,0,0,0,0,0,0
13+
"sys_workspace_stage",,,,,,,,,,,,,,,,,
14+
,"uid","pid","tstamp","deleted","sorting","title","responsible_persons","default_mailcomment","parentid","notification_defaults","allow_notificaton_settings",,,,,
15+
,1,0,1290048921,0,1,"Stage 1","be_users_3",,1,0,0,,,,,
16+
"tt_content",,,,,,,,,,,,,,,,,
17+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header",,,,
18+
,200,88,256,0,0,0,0,0,0,0,0,"Regular Element #0"
19+
,201,88,512,0,-1,0,0,0,0,0,0,"Language all element"
20+
,297,89,384,0,0,0,0,0,0,0,0,"Regular Element #1",,,,
21+
,298,89,512,1,0,0,0,0,0,0,0,"Testing #1",,,,
22+
,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3",,,,
23+
,300,89,1024,0,1,299,299,0,0,0,0,"[Translate to Dansk:] Regular Element #3",,,,
24+
,301,89,384,0,1,297,297,0,0,0,0,"[Translate to Dansk:] Regular Element #1",,,,
25+
,302,89,448,0,2,297,301,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",,,,
26+
"sys_refindex"
27+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
28+
,"02aa95a647ed365ffeeac881bd1af449","pages",91,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
29+
,"14f90231b8565c61decd2aeaebea6034","pages",92,"l10n_parent",0,0,2147483647,0,,,,0,0,"pages",89,,0,0,2147483647,0,0,
30+
,"6f85cfacfff942817392efe26ff1ade0","sys_workspace",1,"custom_stages",0,0,2147483647,0,,,,0,0,"sys_workspace_stage",1,,0,0,2147483647,0,0,
31+
,"96a6b7ec63daee0e0ce5d4908b6eda6f","sys_workspace_stage",1,"responsible_persons",0,0,2147483647,0,,,,0,0,"be_users",3,,0,0,2147483647,0,0,
32+
,"ca4f164be617724388f00923729e8558","tt_content",300,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",299,,0,0,2147483647,0,0,
33+
,"3676712de719382fe386617c1942c940","tt_content",301,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,
34+
,"2b5621b6ac407f06a71e517bf98c9c94","tt_content",302,"l18n_parent",0,0,2147483647,0,,,,0,0,"tt_content",297,,0,0,2147483647,0,0,

0 commit comments

Comments
 (0)