[BUGFIX] Delete modified record in WS just deletes WS version 66/24366/4
authorSascha Egerer <sascha.egerer@dkd.de>
Fri, 4 Oct 2013 09:57:35 +0000 (11:57 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 11 Oct 2013 13:54:44 +0000 (15:54 +0200)
If you edit a record in a workspace and then you try to
delete the record, the record it not deleted but the
version (workspace-change record) is.

Resolves: #52530
Releases: 6.2, 6.1, 6.0
Change-Id: I6a77f9a398276af98c41d841053641f3e07b2e33
Reviewed-on: https://review.typo3.org/24366
Reviewed-by: Thorsten Kahler
Tested-by: Thorsten Kahler
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/version/Classes/Hook/DataHandlerHook.php

index 106491d..12d14ce 100644 (file)
@@ -216,11 +216,28 @@ class DataHandlerHook {
                                                $liveRec = BackendUtility::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state');
                                                // Processing can be skipped if a delete placeholder shall be swapped/published
                                                // during the current request. Thus it will be deleted later on...
-                                               if ($record['t3ver_state'] == 2 && !empty($liveRec['uid']) && !empty($tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['action']) && !empty($tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['swapWith']) && $tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['action'] === 'swap' && $tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['swapWith'] == $id) {
+                                               if ($record['t3ver_state'] == 2 && !empty($liveRec['uid'])
+                                                       && !empty($tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['action'])
+                                                       && !empty($tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['swapWith'])
+                                                       && $tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['action'] === 'swap'
+                                                       && $tcemainObj->cmdmap[$table][$liveRec['uid']]['version']['swapWith'] == $id) {
+
                                                        return NULL;
                                                }
-                                               // Delete those in WS 0 + if their live records state was not "Placeholder".
-                                               if ($record['t3ver_wsid'] == 0 || (int) $liveRec['t3ver_state'] <= 0) {
+
+                                               if ($record['t3ver_wsid'] > 0 && $record['t3ver_state'] == 0) {
+                                                       // Change normal versioned record to delete placeholder
+                                                       // Happens when an edited record is deleted
+                                                       $updateFields = array(
+                                                               't3ver_label' => 'DELETED!',
+                                                               't3ver_state' => 2,
+                                                       );
+                                                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $id, $updateFields);
+                                                       // Delete localization overlays:
+                                                       $tcemainObj->deleteL10nOverlayRecords($table, $id);
+
+                                               } elseif ($record['t3ver_wsid'] == 0 || (int) $liveRec['t3ver_state'] <= 0) {
+                                                       // Delete those in WS 0 + if their live records state was not "Placeholder".
                                                        $tcemainObj->deleteEl($table, $id);
                                                } else {
                                                        // If live record was placeholder (new/deleted), rather clear