[BUGFIX] Publishing delete placeholder affects other workspaces 89/31589/3
authorOliver Hader <oliver@typo3.org>
Fri, 11 Jul 2014 08:49:51 +0000 (10:49 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 13 Aug 2014 14:30:52 +0000 (16:30 +0200)
On publishing a delete placeholder all other versions shall be
deleted as well, since the original record will be deleted after
that action. However, this is only valid for the live workspace
and using the legacy version behavior there.

DataHandler::deleteVersionsForRecord() calls
BackendUtility::selectVersionsOfRecord(), but without the
additional, but required, $workspace argument. Thus, all other
versions in other workspaces are deleted as well. The SQL query
to determine versions needs to be limited to either the live
workspace (for legacy versions) and the current workspace.

Resolves: #60249
Releases: master, 6.2
Change-Id: If90511dc4ac2bc3dde6e58570e6bf10e4ac949db
Reviewed-on: http://review.typo3.org/31589
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/Publish/DataSet/deleteContent.csv
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/Publish/DataSet/deletePage.csv
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/PublishAll/DataSet/deleteContent.csv
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/PublishAll/DataSet/deletePage.csv

index e57407b..d5f509d 100644 (file)
@@ -3634,6 +3634,7 @@ class BackendUtility {
        static public function selectVersionsOfRecord($table, $uid, $fields = '*', $workspace = 0, $includeDeletedRecords = FALSE, $row = NULL) {
                $realPid = 0;
                $outputRows = array();
+               $workspace = (int)$workspace;
                if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                        if (is_array($row) && !$includeDeletedRecords) {
                                $row['_CURRENT_VERSION'] = TRUE;
@@ -3641,25 +3642,28 @@ class BackendUtility {
                                $outputRows[] = $row;
                        } else {
                                // Select UID version:
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'uid=' . (int)$uid . ($includeDeletedRecords ? '' : self::deleteClause($table)));
+                               $row = BackendUtility::getRecord($table, $uid, $fields, '', !$includeDeletedRecords);
                                // Add rows to output array:
-                               if ($res) {
-                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-                                       if ($row) {
-                                               $row['_CURRENT_VERSION'] = TRUE;
-                                               $realPid = $row['pid'];
-                                               $outputRows[] = $row;
-                                       }
-                                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                               if ($row) {
+                                       $row['_CURRENT_VERSION'] = TRUE;
+                                       $realPid = $row['pid'];
+                                       $outputRows[] = $row;
                                }
                        }
                        // Select all offline versions of record:
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, 'pid=-1 AND uid<>' . (int)$uid . ' AND t3ver_oid=' . (int)$uid . ($workspace != 0 ? ' AND t3ver_wsid=' . (int)$workspace : '') . ($includeDeletedRecords ? '' : self::deleteClause($table)), '', 't3ver_id DESC');
+                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                               $fields,
+                               $table,
+                               'pid=-1 AND uid<>' . (int)$uid . ' AND t3ver_oid=' . (int)$uid
+                                       . ' AND t3ver_wsid' . ($workspace !== 0 ? ' IN (0,' . (int)$workspace . ')' : '=0')
+                                       . ($includeDeletedRecords ? '' : self::deleteClause($table)),
+                               '',
+                               't3ver_id DESC'
+                       );
                        // Add rows to output array:
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $outputRows[] = $row;
+                       if (is_array($rows)) {
+                               $outputRows = array_merge($outputRows, $rows);
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        // Set real-pid:
                        foreach ($outputRows as $idx => $oRow) {
                                $outputRows[$idx]['_REAL_PID'] = $realPid;
index 7a1f3cf..65a0b36 100644 (file)
@@ -4266,7 +4266,7 @@ class DataHandler {
         * @todo Define visibility
         */
        public function deleteVersionsForRecord($table, $uid, $forceHardDelete) {
-               $versions = BackendUtility::selectVersionsOfRecord($table, $uid, 'uid,pid');
+               $versions = BackendUtility::selectVersionsOfRecord($table, $uid, 'uid,pid', $this->BE_USER->workspace);
                if (is_array($versions)) {
                        foreach ($versions as $verRec) {
                                if (!$verRec['_CURRENT_VERSION']) {
index 2b5d821..60fdbd5 100644 (file)
@@ -4,5 +4,5 @@ tt_content
 ,298,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #2"
 ,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3"
 ,300,89,1024,0,1,299,0,0,0,0,0,"[Translate to Dansk:] Regular Element #3"
-,301,-1,1000000000,1,0,0,2,2,0,298,0,"Regular Element #2"
+,301,-1,512,0,0,0,2,2,0,298,0,"Regular Element #2"
 ,302,-1,1000000000,1,0,0,0,0,0,298,0,"Regular Element #2"
index 0c14229..b53354f 100644 (file)
@@ -11,5 +11,5 @@ tt_content
 ,298,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #2"
 ,299,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #3"
 ,300,89,1000000000,1,1,299,0,0,0,0,0,"[Translate to Dansk:] Regular Element #3"
-,301,-1,1000000000,1,0,0,2,2,0,298,0,"Regular Element #2"
+,301,-1,512,0,0,0,2,2,0,298,0,"Regular Element #2"
 ,302,-1,1000000000,1,1,299,1,2,0,300,0,"[Translate to Dansk:] Regular Element #3"
index 2b5d821..60fdbd5 100644 (file)
@@ -4,5 +4,5 @@ tt_content
 ,298,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #2"
 ,299,89,768,0,0,0,0,0,0,0,0,"Regular Element #3"
 ,300,89,1024,0,1,299,0,0,0,0,0,"[Translate to Dansk:] Regular Element #3"
-,301,-1,1000000000,1,0,0,2,2,0,298,0,"Regular Element #2"
+,301,-1,512,0,0,0,2,2,0,298,0,"Regular Element #2"
 ,302,-1,1000000000,1,0,0,0,0,0,298,0,"Regular Element #2"
index 0c14229..b53354f 100644 (file)
@@ -11,5 +11,5 @@ tt_content
 ,298,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #2"
 ,299,89,1000000000,1,0,0,0,0,0,0,0,"Regular Element #3"
 ,300,89,1000000000,1,1,299,0,0,0,0,0,"[Translate to Dansk:] Regular Element #3"
-,301,-1,1000000000,1,0,0,2,2,0,298,0,"Regular Element #2"
+,301,-1,512,0,0,0,2,2,0,298,0,"Regular Element #2"
 ,302,-1,1000000000,1,1,299,1,2,0,300,0,"[Translate to Dansk:] Regular Element #3"