[BUGFIX] Take versioned record into account for showHidden flag.
authorBart Dubelaar <bartdubelaar@gmail.com>
Fri, 27 Jan 2012 12:02:49 +0000 (13:02 +0100)
committerXavier Perseguers <xavier@typo3.org>
Tue, 16 Oct 2012 09:13:15 +0000 (11:13 +0200)
The flag showHiddenPage is set if the requested uid is a hidden page.
The original code always looked at the original uid and not to version
in the active workspace. This is fixed.

Change-Id: I4bc9cc0cd37e4a71cbf71cef37e10bf2f8bf3cb5
Fixes: #33392
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/12803
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/cms/tslib/class.tslib_fe.php

index 633ebd5..a7d6dc2 100644 (file)
        }
 
        /**
-        * Checks if the page is hidden. If it is hidden, preview flags will be set.
+        * Checks if the page is hidden in the active workspace.
+        * If it is hidden, preview flags will be set.
         *
         * @return bool
         */
        protected function determineIdIsHiddenPage() {
                $field = t3lib_utility_Math::canBeInterpretedAsInteger($this->id) ? 'uid' : 'alias';
                $pageSelectCondition = $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->id, 'pages');
-               $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid,hidden,starttime,endtime', 'pages',
-                       $pageSelectCondition . ' AND pid>=0 AND deleted=0');
-               $result = is_array($page) && (
-                       $page['hidden'] || $page['starttime'] > $GLOBALS['SIM_EXEC_TIME'] ||
-                               ($page['endtime'] != 0 && $page['endtime'] <= $GLOBALS['SIM_EXEC_TIME'])
+               $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       'uid,hidden,starttime,endtime',
+                       'pages',
+                       $pageSelectCondition . ' AND pid>=0 AND deleted=0'
                );
+               $workspace = $this->whichWorkspace();
+               if ($workspace !== 0 && $workspace !== FALSE) {
+                               // Fetch overlay of page if in workspace and check if it is hidden
+                       $pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
+                       $pageSelectObject->versioningPreview = TRUE;
+                       $pageSelectObject->init(FALSE);
+                       $targetPage = $pageSelectObject->getWorkspaceVersionOfRecord($this->whichWorkspace(), 'pages', $page['uid']);
+                       $result = ($targetPage === -1 || $targetPage === -2);
+               } else {
+                       $result = is_array($page) && (
+                               $page['hidden'] || $page['starttime'] > $GLOBALS['SIM_EXEC_TIME'] ||
+                                       ($page['endtime'] != 0 && $page['endtime'] <= $GLOBALS['SIM_EXEC_TIME'])
+                       );
+               }
                return $result;
        }