[BUGFIX] Take versioned record into account for showHidden flag. 02/12802/3
authorBart Dubelaar <bartdubelaar@gmail.com>
Fri, 27 Jan 2012 12:02:49 +0000 (13:02 +0100)
committerBenjamin Mack <benni@typo3.org>
Sun, 7 Apr 2013 08:08:55 +0000 (10:08 +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: I49017e874fc2accfc9c38789d8d73528afed3c6f
Fixes: #33392
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/12802
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Bart Dubelaar
Tested-by: Bart Dubelaar
Reviewed-by: Stefan Neufeind
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
typo3/sysext/cms/tslib/class.tslib_fe.php

index ade318f..e192d49 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_div::testInt($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;
        }
 
@@ -4913,4 +4927,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_fe.php']);
 }
 
-?>
\ No newline at end of file
+?>