Commit 95d6b579 authored by Susanne Moog's avatar Susanne Moog Committed by Georg Ringer
Browse files

[BUGFIX] Preview pages with publish dates

The view module already adds simTime to pages that have a publish date
set. With this change all places generating page preview links behave 
in the same way, namely adding the simTime commands if the page has
publish date restrictions.

This change reverts f012052f and implements the behavior in a less 
intrusive way.

Resolves: #66451
Releases: master
Change-Id: Idc740477d821ac32cd74dbec7b616b2794165ea9
Reviewed-on: https://review.typo3.org/52098

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 8cb64924
......@@ -719,7 +719,7 @@ class EditDocumentController extends AbstractModule
$this->viewUrl = GeneralUtility::_GP('viewUrl');
$this->recTitle = GeneralUtility::_GP('recTitle');
$this->noView = GeneralUtility::_GP('noView');
$this->perms_clause = $beUser->getPagePermsClause(1);
$this->perms_clause = $beUser->getPagePermsClause(Permission::PAGE_SHOW);
// Set other internal variables:
$this->R_URL_getvars['returnUrl'] = $this->retUrl;
$this->R_URI = $this->R_URL_parts['path'] . '?' . ltrim(GeneralUtility::implodeArrayForUrl(
......
......@@ -1026,7 +1026,7 @@ class PageLayoutController
*
***************************/
/**
* This creates the buttons for die modules
* This creates the buttons for the modules
*
* @return void
*/
......
......@@ -34,6 +34,7 @@ use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -3014,6 +3015,9 @@ class BackendUtility
if ($alternativeUrl) {
$previewUrl = $viewScript;
} else {
$permissionClause = $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW);
$pageInfo = self::readPageAccess($pageUid, $permissionClause);
$additionalGetVars .= self::ADMCMD_previewCmds($pageInfo);
$previewUrl = self::createPreviewUrl($pageUid, $rootLine, $anchorSection, $additionalGetVars, $viewScript);
}
......
......@@ -64,7 +64,7 @@ class FrontendRestrictionContainer extends AbstractRestrictionContainer
foreach ($this->restrictions as $restriction) {
foreach ($queriedTables as $tableAlias => $tableName) {
$disableRestriction = false;
if ($restriction instanceof HiddenRestriction || $restriction instanceof StartTimeRestriction || $restriction instanceof EndTimeRestriction) {
if ($restriction instanceof HiddenRestriction) {
// If display of hidden records is requested, we must disable the hidden restriction.
$disableRestriction = $tableName === 'pages' ? $typoScriptFrontendController->showHiddenPage : $typoScriptFrontendController->showHiddenRecords;
}
......
......@@ -47,7 +47,7 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
'hiddenPagePreview' => true,
'hiddenRecordPreview' => true,
'feGroupList' => '0,-1',
'expectedSQL' => '("aTable"."deleted" = 0) AND (("aTable"."t3ver_state" <= 0) AND ("aTable"."pid" <> -1)) AND (("aTable"."myGroupField" IS NULL) OR ("aTable"."myGroupField" = \'\') OR ("aTable"."myGroupField" = \'0\') OR (FIND_IN_SET(\'0\', "aTable"."myGroupField")) OR (FIND_IN_SET(\'-1\', "aTable"."myGroupField")))'
'expectedSQL' => '("aTable"."deleted" = 0) AND (("aTable"."t3ver_state" <= 0) AND ("aTable"."pid" <> -1)) AND ("aTable"."myStartTimeField" <= 42) AND (("aTable"."myEndTimeField" = 0) OR ("aTable"."myEndTimeField" > 42)) AND (("aTable"."myGroupField" IS NULL) OR ("aTable"."myGroupField" = \'\') OR ("aTable"."myGroupField" = \'0\') OR (FIND_IN_SET(\'0\', "aTable"."myGroupField")) OR (FIND_IN_SET(\'-1\', "aTable"."myGroupField")))'
],
'Workspace, with WS preview' => [
'tableName' => 'aTable',
......@@ -65,7 +65,7 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
'hiddenPagePreview' => true,
'hiddenRecordPreview' => true,
'feGroupList' => '0,-1',
'expectedSQL' => '("aTable"."deleted" = 0) AND ((("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 1)) AND ("aTable"."pid" <> -1)) AND (("aTable"."myGroupField" IS NULL) OR ("aTable"."myGroupField" = \'\') OR ("aTable"."myGroupField" = \'0\') OR (FIND_IN_SET(\'0\', "aTable"."myGroupField")) OR (FIND_IN_SET(\'-1\', "aTable"."myGroupField")))'
'expectedSQL' => '("aTable"."deleted" = 0) AND ((("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 1)) AND ("aTable"."pid" <> -1)) AND ("aTable"."myStartTimeField" <= 42) AND (("aTable"."myEndTimeField" = 0) OR ("aTable"."myEndTimeField" > 42)) AND (("aTable"."myGroupField" IS NULL) OR ("aTable"."myGroupField" = \'\') OR ("aTable"."myGroupField" = \'0\') OR (FIND_IN_SET(\'0\', "aTable"."myGroupField")) OR (FIND_IN_SET(\'-1\', "aTable"."myGroupField")))'
],
'Live page, no preview' => [
'tableName' => 'pages',
......@@ -83,7 +83,7 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
'hiddenPagePreview' => true,
'hiddenRecordPreview' => true,
'feGroupList' => '0,-1',
'expectedSQL' => '("pages"."deleted" = 0) AND (("pages"."t3ver_state" <= 0) AND ("pages"."pid" <> -1)) AND (("pages"."fe_group" IS NULL) OR ("pages"."fe_group" = \'\') OR ("pages"."fe_group" = \'0\') OR (FIND_IN_SET(\'0\', "pages"."fe_group")) OR (FIND_IN_SET(\'-1\', "pages"."fe_group")))'
'expectedSQL' => '("pages"."deleted" = 0) AND (("pages"."t3ver_state" <= 0) AND ("pages"."pid" <> -1)) AND ("pages"."starttime" <= 42) AND (("pages"."endtime" = 0) OR ("pages"."endtime" > 42)) AND (("pages"."fe_group" IS NULL) OR ("pages"."fe_group" = \'\') OR ("pages"."fe_group" = \'0\') OR (FIND_IN_SET(\'0\', "pages"."fe_group")) OR (FIND_IN_SET(\'-1\', "pages"."fe_group")))'
],
'Workspace page, with WS preview' => [
'tableName' => 'pages',
......@@ -101,7 +101,7 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
'hiddenPagePreview' => true,
'hiddenRecordPreview' => true,
'feGroupList' => '0,-1',
'expectedSQL' => '("pages"."deleted" = 0) AND ("pages"."pid" <> -1) AND (("pages"."fe_group" IS NULL) OR ("pages"."fe_group" = \'\') OR ("pages"."fe_group" = \'0\') OR (FIND_IN_SET(\'0\', "pages"."fe_group")) OR (FIND_IN_SET(\'-1\', "pages"."fe_group")))'
'expectedSQL' => '("pages"."deleted" = 0) AND ("pages"."pid" <> -1) AND ("pages"."starttime" <= 42) AND (("pages"."endtime" = 0) OR ("pages"."endtime" > 42)) AND (("pages"."fe_group" IS NULL) OR ("pages"."fe_group" = \'\') OR ("pages"."fe_group" = \'0\') OR (FIND_IN_SET(\'0\', "pages"."fe_group")) OR (FIND_IN_SET(\'-1\', "pages"."fe_group")))'
],
];
}
......
......@@ -1376,11 +1376,11 @@ class PageRepository
$field = $table . '.' . $ctrl['enablecolumns']['disabled'];
$constraints[] = $expressionBuilder->eq($field, 0);
}
if ($ctrl['enablecolumns']['starttime'] && !$show_hidden && !$ignore_array['starttime']) {
if ($ctrl['enablecolumns']['starttime'] && !$ignore_array['starttime']) {
$field = $table . '.' . $ctrl['enablecolumns']['starttime'];
$constraints[] = $expressionBuilder->lte($field, (int)$GLOBALS['SIM_ACCESS_TIME']);
}
if ($ctrl['enablecolumns']['endtime'] && !$show_hidden && !$ignore_array['endtime']) {
if ($ctrl['enablecolumns']['endtime'] && !$ignore_array['endtime']) {
$field = $table . '.' . $ctrl['enablecolumns']['endtime'];
$constraints[] = $expressionBuilder->orX(
$expressionBuilder->eq($field, 0),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment