[BUGFIX] Don't show duplicates in workspace preview 75/24075/2
authorTimo Webler <timo.webler@dkd.de>
Thu, 26 Sep 2013 16:04:02 +0000 (18:04 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 11 Oct 2013 13:20:28 +0000 (15:20 +0200)
Fixes workspace filter conditions in case of workspace preview in
t3lib_pageSelect::enableFields().

Additionally cleared up the corresponding comments.

Change-Id: I088928a88cb673f18f218ef691a6c528019317c0
Fixes: #37065
Releases: 6.2, 6.1, 6.0, 4.5
Reviewed-on: https://review.typo3.org/24075
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
t3lib/class.t3lib_page.php

index 9e3ab5d..e6f5ed8 100644 (file)
@@ -1089,9 +1089,26 @@ class t3lib_pageSelect {
                                $query .= ' AND ' . $table . '.' . $ctrl['delete'] . '=0';
                        }
 
-                               // Filter out new place-holder records in case we are NOT in a versioning preview (that means we are online!)
-                       if ($ctrl['versioningWS'] && !$this->versioningPreview) {
-                               $query .= ' AND ' . $table . '.t3ver_state<=0 AND ' . $table . '.pid<>-1'; // Shadow state for new items MUST be ignored!
+                       if ($ctrl['versioningWS']) {
+                               if (!$this->versioningPreview) {
+                                       // Filter out placeholder records (new/moved/deleted items)
+                                       // in case we are NOT in a versioning preview (that means we are online!)
+                                       $query .= ' AND ' . $table . '.t3ver_state<=0';
+                               } else {
+                                       if ($table !== 'pages') {
+                                               // show only records of live and of the current workspace
+                                               // in case we are in a versioning preview
+                                               $query .= ' AND ('
+                                                       . $table . '.t3ver_wsid=0 OR '
+                                                       . $table . '.t3ver_wsid=' . intval($this->versioningWorkspaceId)
+                                                       . ')';
+                                       }
+                               }
+
+                               // Filter out versioned records
+                               if (!$noVersionPreview) {
+                                       $query .= ' AND ' . $table . '.pid<>-1';
+                               }
                        }
 
                                // Enable fields: