[BUGFIX] Don't show duplicates in workspace preview
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / PageRepository.php
index 63c302c..9640cf3 100644 (file)
@@ -866,11 +866,28 @@ class PageRepository {
                        if ($ctrl['delete']) {
                                $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) {
-                               // Shadow state for new items MUST be ignored!
-                               $query .= ' AND ' . $table . '.t3ver_state<=0 AND ' . $table . '.pid<>-1';
+                       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:
                        if (is_array($ctrl['enablecolumns'])) {
                                // In case of versioning-preview, enableFields are ignored (checked in versionOL())