Skip to content

Commit

Permalink
[BUGFIX] Make tstemplate respect hidden flags for sys_template records
Browse files Browse the repository at this point in the history
Previously, the tstemplate Object Browser would wrongly show hidden
typoscript templates, if they were the first one to be found
(which determined by the sorting key).
The hidden flag will now only be ignored, if a hidden template is
explicitly requested by its uid (using the template selector switch).

Resolves: #88507
Releases: main, 11.5
Change-Id: Ibbfeb2de7f8ee79a1e343ff23f9d1064219eb344
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63516
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Jan 12, 2022
1 parent d85d362 commit 8c5aefa
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Localization\LanguageService;
Expand Down Expand Up @@ -143,15 +145,21 @@ protected function initialize_editor($pageId, $template_uid = 0)
// Defined global here!
$this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);

$this->templateRow = $this->templateService->ext_getFirstTemplate($pageId, $template_uid);
$hasFirstTemplate = is_array($this->templateRow);
// No explicitly selected template on this page was found, so we behave like the Frontend (e.g. when a template is hidden but on the page above)
if (!$hasFirstTemplate) {
// Re-initiatlize the templateService but do not include hidden templates
$context = clone GeneralUtility::makeInstance(Context::class);
$context->setAspect('visibility', GeneralUtility::makeInstance(VisibilityAspect::class));
$this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class, $context);
}
// Gets the rootLine
$rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $pageId);
$rootLine = $rootlineUtility->get();
// This generates the constants/config + hierarchy info for the template.
$this->templateService->runThroughTemplates($rootLine, $template_uid);

// Get the row of the first VISIBLE template of the page. whereclause like the frontend.
$this->templateRow = $this->templateService->ext_getFirstTemplate($pageId, $template_uid);
return is_array($this->templateRow);
return $hasFirstTemplate;
}

/**
Expand Down

0 comments on commit 8c5aefa

Please sign in to comment.