[BUGFIX] WS preview shows pages changes from all WS 73/24573/2
authorThorsten Kahler <thorsten.kahler@typo3.org>
Thu, 7 Feb 2013 10:14:25 +0000 (11:14 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 11 Oct 2013 14:16:31 +0000 (16:16 +0200)
In workspace preview the query condition for pages records has to be
enhanced to restrict to live WS and current WS.

Change-Id: Ib271b9bb435b50f2777621707728a74ba5de4187
Fixes: #37209
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/24573
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php

index eb22809..de2e202 100644 (file)
@@ -146,11 +146,14 @@ class PageRepository {
                if (!$this->versioningPreview) {
                        $this->where_hid_del .= ' AND NOT pages.t3ver_state>0';
                } else {
-                       // For version previewing, make sure that enable-fields are not de-selecting hidden pages - we need versionOL() to unset them only if the overlay record instructs us to.
+                       // For version previewing, make sure that enable-fields are not de-selecting hidden
+                       // pages - we need versionOL() to unset them only if the overlay record instructs us to.
                        // Copy where_hid_del to other variable (used in relation to versionOL())
                        $this->versioningPreview_where_hid_del = $this->where_hid_del;
                        // Clear where_hid_del
                        $this->where_hid_del = ' AND pages.deleted=0 ';
+                       // Restrict to live and current workspaces
+                       $this->where_hid_del .= ' AND (pages.t3ver_wsid=0 OR pages.t3ver_wsid=' . intval($this->versioningWorkspaceId) . ')';
                }
        }
 
index a681bb4..823397f 100644 (file)
@@ -120,6 +120,64 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                )));
        }
 
+       ////////////////////////////////
+// Tests concerning workspaces
+////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function noPagesFromWorkspaceAreShownLive() {
+               // initialization
+               $wsid = 987654321;
+
+               // simulate calls from tslib_fe->fetch_the_id()
+               $this->pageSelectObject->versioningPreview = FALSE;
+               $this->pageSelectObject->versioningWorkspaceId = $wsid;
+               $this->pageSelectObject->init(FALSE);
+
+               // check SQL created by t3lib_pageSelect->getPage()
+               $GLOBALS['TYPO3_DB']->expects($this->once())
+                       ->method('exec_SELECTquery')
+                       ->with(
+                       '*',
+                       'pages',
+                       $this->logicalAnd(
+                               $this->logicalNot(
+                                       $this->stringContains('(pages.t3ver_wsid=0 or pages.t3ver_wsid=' . $wsid . ')')
+                               ),
+                               $this->stringContains('AND NOT pages.t3ver_state>0')
+                       )
+               );
+
+               $this->pageSelectObject->getPage(1);
+
+       }
+
+       /**
+        * @test
+        */
+       public function previewShowsPagesFromLiveAndCurrentWorkspace() {
+               // initialization
+               $wsid = 987654321;
+
+               // simulate calls from tslib_fe->fetch_the_id()
+               $this->pageSelectObject->versioningPreview = TRUE;
+               $this->pageSelectObject->versioningWorkspaceId = $wsid;
+               $this->pageSelectObject->init(FALSE);
+
+               // check SQL created by t3lib_pageSelect->getPage()
+               $GLOBALS['TYPO3_DB']->expects($this->once())
+                       ->method('exec_SELECTquery')
+                       ->with(
+                       '*',
+                       'pages',
+                       $this->stringContains('(pages.t3ver_wsid=0 or pages.t3ver_wsid=' . $wsid . ')')
+               );
+
+               $this->pageSelectObject->getPage(1);
+
+       }
 
        ////////////////////////////////
        // Tests concerning versioning
@@ -176,8 +234,4 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND tt_content.t3ver_state<=0')), 'No versioning placeholders');
                $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND tt_content.pid<>-1')), 'No ecords from page -1');
        }
-
-
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file