Commit fec78269 authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[TASK] Streamline TSFE-related config properties

Some default properties in TypoScript have
been modified back then with the TypoScript
condition [compatVersion > 4.0] which has been
removed years ago.

This code replaces the leftover functionality
and explicitly checks the occurrences with default
values.

In addition, the more performant "array_replace_recursive"
function is used for the page.config merging.

Resolves: #96885
Releases: main
Change-Id: I3dbd4e0b8c105a31e8babd0c5da0ca4ecc9c42d7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73483

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent b843e0da
......@@ -50,13 +50,13 @@ trait DefaultJavaScriptAssetTrait
{
/** @var ?TypoScriptFrontendController $frontendController */
$frontendController = $GLOBALS['TSFE'] ?? null;
return ($frontendController->config['config']['removeDefaultJS'] ?? '') === '1';
return $frontendController && ($frontendController->config['config']['removeDefaultJS'] ?? 'external') === '1';
}
protected function shallExportDefaultFrontendJavaScript(): bool
{
/** @var ?TypoScriptFrontendController $frontendController */
$frontendController = $GLOBALS['TSFE'] ?? null;
return ($frontendController->config['config']['removeDefaultJS'] ?? '') === 'external';
return $frontendController && ($frontendController->config['config']['removeDefaultJS'] ?? 'external') === 'external';
}
}
......@@ -59,7 +59,6 @@ use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Type\Bitmask\PageTranslationVisibility;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
......@@ -1602,22 +1601,12 @@ class TypoScriptFrontendController implements LoggerAwareInterface
}
// Filling the config-array, first with the main "config." part
if (is_array($this->tmpl->setup['config.'] ?? null)) {
ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
$this->tmpl->setup['config.'] = array_replace_recursive($this->tmpl->setup['config.'], $this->config['config']);
$this->config['config'] = $this->tmpl->setup['config.'];
}
// override it with the page/type-specific "config."
if (is_array($this->pSetup['config.'] ?? null)) {
ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
}
// Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
if (!isset($this->config['config']['removeDefaultJS'])) {
$this->config['config']['removeDefaultJS'] = 'external';
}
if (!isset($this->config['config']['inlineStyle2TempFile'])) {
$this->config['config']['inlineStyle2TempFile'] = 1;
}
if (!isset($this->config['config']['compressJs'])) {
$this->config['config']['compressJs'] = 0;
$this->config['config'] = array_replace_recursive($this->config['config'], $this->pSetup['config.']);
}
// Rendering charset of HTML page.
if (isset($this->config['config']['metaCharset']) && $this->config['config']['metaCharset'] !== 'utf-8') {
......@@ -2120,9 +2109,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
// linkVars
$this->calculateLinkVars($request->getQueryParams());
// Setting XHTML-doctype from doctype
if (!isset($this->config['config']['xhtmlDoctype']) || !$this->config['config']['xhtmlDoctype']) {
$this->config['config']['xhtmlDoctype'] = $this->config['config']['doctype'] ?? '';
}
$this->config['config']['xhtmlDoctype'] = $this->config['config']['xhtmlDoctype'] ?? $this->config['config']['doctype'] ?? '';
if ($this->config['config']['xhtmlDoctype']) {
$this->xhtmlDoctype = $this->config['config']['xhtmlDoctype'];
// Checking XHTML-docytpe
......
......@@ -694,11 +694,12 @@ class RequestHandler implements RequestHandlerInterface
$controller->INTincScript_loadJSCode();
// Javascript inline code
$inlineJS = $controller->cObj->cObjGet($controller->pSetup['jsInline.'] ?? null, 'jsInline.');
$inlineJS = (string)$controller->cObj->cObjGet($controller->pSetup['jsInline.'] ?? null, 'jsInline.');
// Javascript inline code for Footer
$inlineFooterJs = $controller->cObj->cObjGet($controller->pSetup['jsFooterInline.'] ?? null, 'jsFooterInline.');
$inlineFooterJs = (string)$controller->cObj->cObjGet($controller->pSetup['jsFooterInline.'] ?? null, 'jsFooterInline.');
$compressJs = (bool)($controller->config['config']['compressJs'] ?? false);
if (($controller->config['config']['removeDefaultJS'] ?? '') === 'external') {
// this option is set to "external" as default
if (($controller->config['config']['removeDefaultJS'] ?? 'external') === 'external') {
/*
* This keeps inlineJS from *_INT Objects from being moved to external files.
* At this point in frontend rendering *_INT Objects only have placeholders instead
......@@ -876,7 +877,8 @@ class RequestHandler implements RequestHandlerInterface
*/
protected function addCssToPageRenderer(TypoScriptFrontendController $controller, string $cssStyles, bool $excludeFromConcatenation, string $inlineBlockName)
{
if (empty($controller->config['config']['inlineStyle2TempFile'] ?? false)) {
// This option is enabled by default on purpose
if (empty($controller->config['config']['inlineStyle2TempFile'] ?? true)) {
$this->getPageRenderer()->addCssInlineBlock($inlineBlockName, $cssStyles, !empty($controller->config['config']['compressCss'] ?? false));
} else {
$this->getPageRenderer()->addCssFile(
......
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