Commit 5e7cad94 authored by Christian Kuhn's avatar Christian Kuhn Committed by Anja Leichsenring
Browse files

[TASK] Make workspace delete a discard

When deleting a record in workspaces that has been
changed in comparison to live - if it is a new, a moved
or a changed workspace record, those records where subject
to the 'soft-delete' strategy of the core: Soft-delete
enabled tables like pages or tt_content did set deleted=1
for those records instead of fully deleting them from the
table. The idea was to allow 'undelete' via recycler or
history module if those records have been deleted by
accident.

However, the undelete workspace records functionality
never worked and has never been fixed. The oldest open
forge issue on this topic is 11 (!) years old.

The solution is to discard those records instead of
soft-deleting them. This effectively drops soft-delete
for workspace records. It's done by a trivial switch in
the main DataHandler delete method to re-route workspace
delete operation to the recently refactored discard
methods instead.

This change allows us to further refactor the remaining
tasks the DataHandler delete functionality is concerned
with, since delete still handles three things:
* Deleting and soft-deleting records in live.
* Creating 'delete placeholder' records in workspaces.
  This is the 'mark the record as to-be-deleted in live
  on workspace publish' operation.
* Undeleting records using recycler and partially the
  history module.

Dropping the workspace-delete scenarios reduces complexity
significantly. The codebase can now be changed with upcoming
patches to separate remaining concerns - similar to what has
been done with discard already. The according scenarios will
see improved test coverage and far better understandable
code along the way. This will ultimately allow us to
fix remaining bugs in this area on one hand and to
improve user experience on the other hand.

Change-Id: I33e1258cb6205668511933c0d9b225f4470655e7
Resolves: #93121
Resolves: #21299
Resolves: #89383
Releases: master
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67191

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 5f3463c2
......@@ -4571,6 +4571,13 @@ class DataHandler implements LoggerAwareInterface
public function deleteAction($table, $id)
{
$recordToDelete = BackendUtility::getRecord($table, $id);
if (is_array($recordToDelete) && isset($recordToDelete['t3ver_wsid']) && (int)$recordToDelete['t3ver_wsid'] !== 0) {
// When dealing with a workspace record, use discard.
$this->discard($table, null, $recordToDelete);
return;
}
// Record asked to be deleted was found:
if (is_array($recordToDelete)) {
$recordWasDeleted = false;
......
.. include:: ../../Includes.txt
===================================================
Important: #93121 - Workspace records are discarded
===================================================
See :issue:`93121`
Description
===========
The delete behavior for records that have been changed in workspaces has
been changed: When a user in a non-live workspace uses the delete button
(waste bin symbol in list or page module) on a record that has a workspace
overlay, those records are discarded now.
Technically, the record in question, plus directly attached 'child' records
like inline relations are now fully deleted from the database with this
operation. They are not 'soft-deleted' anymore, as it happens with records
of soft-delete-enabled tables in a live workspace.
This is good and bad from a UX point of view: The delete behavior in workspaces
page and list module and the 'discard' behavior in workspace module are now
identical, which simplifies things for users. On the other hand, discarded
workspace records can not be 'undeleted' anymore using the recycler module.
The recycler and history modules however did not work well with workspaces,
only very simple scenarios did sometimes lead to the expected result. The
recycler module is now hidden for users in non-live workspace.
Note there is a second scenario: When deleting a record in page or list module
that has NOT been changed in this workspace, this record is marked as
to be deleted in live during publish. Technically a 'delete placeholder'
is created in this case. This important difference is currently not reflected
well in page and list module. Further TYPO3 core v11 changes will improve this
situation usability wise. The change of the delete behavior allows us to
work in this area to ultimately end up with a satisfying user experience.
.. index:: Backend, Database, ext:workspaces
......@@ -11,6 +11,7 @@ defined('TYPO3') or die();
[
'routeTarget' => \TYPO3\CMS\Recycler\Controller\RecyclerModuleController::class . '::handleRequest',
'access' => 'user,group',
'workspaces' => 'online',
'name' => 'web_RecyclerRecycler',
'icon' => 'EXT:recycler/Resources/Public/Icons/module-recycler.svg',
'labels' => 'LLL:EXT:recycler/Resources/Private/Language/locallang_mod.xlf',
......
......@@ -29,7 +29,6 @@
,127,89,0,0,0,0,0,0,0,21,330,"tt_content","image",1,"sys_file","Kasper",,,
,128,89,0,0,0,0,0,0,0,21,331,"tt_content","image",1,"sys_file","Taken at T3BOARD",,,
,129,89,0,0,0,0,0,0,0,1,331,"tt_content","image",2,"sys_file","This is Kasper",,,
,130,89,1,0,0,1,1,0,0,1,332,"tt_content","image",1,"sys_file","Image #1",,,
"tt_content",,,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","image",,,,,,,
,330,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,,,,,
......
......@@ -29,7 +29,6 @@
,127,89,0,0,0,0,0,0,0,21,330,"tt_content","image",1,"sys_file","Kasper",,,
,128,89,0,0,0,0,0,0,0,21,331,"tt_content","image",1,"sys_file","Taken at T3BOARD",,,
,129,89,0,0,0,0,0,0,0,1,331,"tt_content","image",2,"sys_file","This is Kasper",,,
,130,89,1,0,0,1,1,0,0,1,332,"tt_content","image",1,"sys_file","Image #1",,,
"tt_content",,,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","image",,,,,,,
,330,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,,,,,
......
......@@ -29,7 +29,6 @@
,127,89,0,0,0,0,0,0,0,21,330,"tt_content","image",1,"sys_file","Kasper",,,
,128,89,0,0,0,0,0,0,0,21,331,"tt_content","image",1,"sys_file","Taken at T3BOARD",,,
,129,89,0,0,0,0,0,0,0,1,331,"tt_content","image",2,"sys_file","This is Kasper",,,
,130,89,1,0,0,1,1,0,0,1,332,"tt_content","image",1,"sys_file","Image #1",,,
"tt_content",,,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","image",,,,,,,
,330,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,,,,,
......
......@@ -29,7 +29,6 @@
,127,89,0,0,0,0,0,0,0,21,330,"tt_content","image",1,"sys_file","Kasper",,,
,128,89,0,0,0,0,0,0,0,21,331,"tt_content","image",1,"sys_file","Taken at T3BOARD",,,
,129,89,0,0,0,0,0,0,0,1,331,"tt_content","image",2,"sys_file","This is Kasper",,,
,130,89,1,0,0,1,1,0,0,1,332,"tt_content","image",1,"sys_file","Image #1",,,
"tt_content",,,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","image",,,,,,,
,330,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,,,,,
......
......@@ -4,7 +4,6 @@
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,
,91,88,256,1,1,89,0,1,1,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,
"sys_workspace",,,,,,,,,,,,,,,,,
,"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"
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
......@@ -29,7 +28,6 @@
,311,90,512,0,0,1,0,310,310,0,0,0,0,"[Translate to Dansk:] Regular Element #10",,,
,312,90,768,0,0,2,0,311,311,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #10",,,
,320,89,512,0,0,0,0,0,298,2,2,0,298,"Regular Element #2",,,
,321,89,416,0,1,1,298,298,298,1,1,0,0,"[Translate to Dansk:] Regular Element #2",,,
"sys_refindex",,,,,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",,,,,
,"01a3ce8c4e3b2bb1aa439dc29081f996","sys_workspace_stage",1,"responsible_persons",,,,0,0,"be_users",3,,,,,,
......
......@@ -4,7 +4,6 @@
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,
,91,88,256,1,1,89,0,1,1,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,
"sys_workspace",,,,,,,,,,,,,,,,,
,"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"
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
......@@ -29,7 +28,6 @@
,311,90,512,0,0,1,0,310,310,0,0,0,0,"[Translate to Dansk:] Regular Element #10",,,
,312,90,768,0,0,2,0,311,311,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #10",,,
,320,89,512,0,0,0,0,0,298,2,2,0,298,"Regular Element #2",,,
,321,89,416,0,1,1,298,298,298,1,1,0,0,"[Translate to Dansk:] Regular Element #2",,,
"sys_refindex",,,,,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",,,,,
,"01a3ce8c4e3b2bb1aa439dc29081f996","sys_workspace_stage",1,"responsible_persons",,,,0,0,"be_users",3,,,,,,
......
......@@ -4,7 +4,6 @@
,88,1,256,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,,,
,89,88,256,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,,,
,90,88,512,0,0,0,0,0,0,0,0,"Target","/data-handler/target",,,,
,91,88,256,1,1,89,0,1,1,0,0,"[Translate to Dansk:] Relations","/data-handler/translate-to-dansk-relations",,,,
"sys_workspace",,,,,,,,,,,,,,,,,
,"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"
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
......@@ -29,7 +28,6 @@
,311,90,512,0,0,1,0,310,310,0,0,0,0,"[Translate to Dansk:] Regular Element #10",,,
,312,90,768,0,0,2,0,311,311,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #10",,,
,320,89,512,0,0,0,0,0,298,2,2,0,298,"Regular Element #2",,,
,321,89,416,0,1,1,298,298,298,1,1,0,0,"[Translate to Dansk:] Regular Element #2",,,
"sys_refindex",,,,,,,,,,,,,,,,,
,"hash","tablename","recuid","field","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_string",,,,,
,"01a3ce8c4e3b2bb1aa439dc29081f996","sys_workspace_stage",1,"responsible_persons",,,,0,0,"be_users",3,,,,,,
......
Markdown is supported
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