[BUGFIX] process_datamap doesn't handle existing versions by itself
authorBart Dubelaar <bartdubelaar@gmail.com>
Fri, 27 Jan 2012 12:54:35 +0000 (13:54 +0100)
committerSusanne Moog <typo3@susannemoog.de>
Sun, 11 Mar 2012 14:21:34 +0000 (15:21 +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: I1e41172b0cc1e04a4822147f3c48ca272b69467c
Fixes: #32780
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/8721
Reviewed-by: Stefan Neufeind
Reviewed-by: Wouter Wolters
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
t3lib/class.t3lib_tcemain.php

index 5eccc82..7963364 100644 (file)
@@ -586,9 +586,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)) {
-                                                                                       /** @var $tce t3lib_TCEmain */
+                                                                               } elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
                                                                                        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                                                                        /* @var $tce t3lib_TCEmain  */
                                                                                        $tce->stripslashes_values = 0;