[BUGFIX] process_datamap doesn't handle existing versions by itself
authorBart Dubelaar <bartdubelaar@gmail.com>
Wed, 25 Jan 2012 13:14:28 +0000 (14:14 +0100)
committerSusanne Moog <typo3@susannemoog.de>
Sun, 11 Mar 2012 14:22:45 +0000 (15:22 +0100)
The process_datamap function in TCEmain expects to receive the ids of the
existing offline counterparts of a record whenever operations are performed in a
workspace. This implies that this has taken into account in all places where
the process_datamap function is called. In some cases this is not properly done, see
bug #32780 and related. The process_cmdmap function does handle this transparently,
so it is desirable to have the same behavior in process_datamap.

This fix implements the translation to versioned records for operations on a single record.
Operations with child records (IRRE) still require the versioned id's, no bugs
 are known that would require this behavior to be changed.

Change-Id: I26618f6b2d4f694a7b5b9b14e1c3d0c343a900ce
Fixes: #32780
Releases: 4.5
Reviewed-on: http://review.typo3.org/8688
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
t3lib/class.t3lib_tcemain.php

index fe8513c..6316f36 100644 (file)
@@ -763,8 +763,14 @@ class t3lib_TCEmain {
                                                                        } elseif (!$this->bypassWorkspaceRestrictions && $errorCode = $this->BE_USER->workspaceCannotEditRecord($table, $tempdata)) {
                                                                                $recordAccess = FALSE; // Versioning is required and it must be offline version!
 
+                                                                                       // Check if there already is a workspace version
+                                                                               $WSversion = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid,t3ver_oid');
+                                                                               if($WSversion) {
+                                                                                       $id = $WSversion['uid'];
+                                                                                       $recordAccess = TRUE;
+
                                                                                        // Auto-creation of version: In offline workspace, test if versioning is enabled and look for workspace version of input record. If there is no versionized record found we will create one and save to that.
-                                                                               if ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
+                                                                               } elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
                                                                                        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                                                                        /* @var $tce t3lib_TCEmain  */
                                                                                        $tce->stripslashes_values = 0;