Skip to content

Commit

Permalink
[!!!][TASK] Remove "sys_template.nextLevel"
Browse files Browse the repository at this point in the history
The special handling "nextLevel" in TypoScript templates
to only load a specific sys_template on the next level (subpages and
further down the rootline) but not on the current level,
is removed.

It is recommended to use proper inclusions and TypoScript
conditions instead.

This reduces complexity within the TemplateService parser,
and for newcomers a very confusing option after gathering
some feedback on this topic.

The database field "sys_template.nextLevel" is therefore
removed.

Resolves: #88640
Releases: master
Change-Id: I06e14d6dfbde82eb36f2ffc30b61bd9870906246
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61158
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
bmack authored and ervaude committed Jun 28, 2019
1 parent e87eb75 commit dfbee19
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 61 deletions.
Expand Up @@ -679,7 +679,6 @@ public function ext_getTemplateHierarchyArr($arr, $depthData, $keyArray, $first
<td align="center">' . ($row['clConst'] ? $statusCheckedIcon : '') . '</td>
<td align="center">' . ($row['pid'] ?: '') . '</td>
<td align="center">' . ($RL >= 0 ? $RL : '') . '</td>
<td>' . ($row['next'] ? $row['next'] : '') . '</td>
</tr>';
if ($deeper) {
$keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : '<span class="treeline-icon treeline-icon-' . $LN . '"></span>'), $keyArray);
Expand Down
37 changes: 0 additions & 37 deletions typo3/sysext/core/Classes/TypoScript/TemplateService.php
Expand Up @@ -159,13 +159,6 @@ class TemplateService
*/
protected $hierarchyInfoToRoot = [];

/**
* Next-level flag (see runThroughTemplates())
*
* @var int
*/
protected $nextLevel = 0;

/**
* The Page UID of the root page
*
Expand Down Expand Up @@ -535,28 +528,6 @@ public function runThroughTemplates($theRootLine, $start_template_uid = 0)
$c = count($this->absoluteRootLine);
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_template');
for ($a = 0; $a < $c; $a++) {
// If some template loaded before has set a template-id for the next level, then load this template first!
if ($this->nextLevel) {
$queryBuilder->setRestrictions($this->queryBuilderRestrictions);
$queryResult = $queryBuilder
->select('*')
->from('sys_template')
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($this->nextLevel, \PDO::PARAM_INT)
)
)
->execute();
$this->nextLevel = 0;
if ($row = $queryResult->fetch()) {
$this->versionOL($row);
if (is_array($row)) {
$this->processTemplate($row, 'sys_' . $row['uid'], $this->absoluteRootLine[$a]['uid'], 'sys_' . $row['uid']);
}
}
}

$where = [
$queryBuilder->expr()->eq(
'pid',
Expand Down Expand Up @@ -702,7 +673,6 @@ public function processTemplate($row, $idList, $pid, $templateID = '', $template
// Creating hierarchy information; Used by backend analysis tools
$this->hierarchyInfo[] = ($this->hierarchyInfoToRoot[] = [
'root' => trim($row['root'] ?? ''),
'next' => $row['nextLevel'] ?? null,
'clConst' => $clConst,
'clConf' => $clConf,
'templateID' => $templateID,
Expand All @@ -727,12 +697,6 @@ public function processTemplate($row, $idList, $pid, $templateID = '', $template
$this->rootId = $pid;
$this->rootLine = [];
}
// If a template is set to be active on the next level set this internal value to point to this UID. (See runThroughTemplates())
if ($row['nextLevel'] ?? null) {
$this->nextLevel = $row['nextLevel'];
} else {
$this->nextLevel = 0;
}
}

/**
Expand Down Expand Up @@ -1240,7 +1204,6 @@ protected function addDefaultTypoScript()
$rootTemplateId = $this->hierarchyInfo[count($this->hierarchyInfo) - 1]['templateID'] ?? null;
$defaultTemplateInfo = [
'root' => '',
'next' => '',
'clConst' => '',
'clConf' => '',
'templateID' => '_defaultTypoScript_',
Expand Down
@@ -0,0 +1,49 @@
.. include:: ../../Includes.txt

========================================================================================================
Breaking: #88640 - Database field "sys_template.nextLevel" and TypoScript sublevel - inheritance removed
========================================================================================================

See :issue:`88640`

Description
===========

The database field `nextLevel` of the database table `sys_template` where TypoScript configuration
is stored, has been removed.

The field `nextLevel` was introduced in TYPO3 v3.x before TypoScript could be imported from
external files.

Nowadays, TypoScript conditions should be used much more instead of this `nextLevel` feature,
which is kind of a pseudo-condition.


Impact
======

The database field is removed, and not evaluated anymore in TypoScript compilation.

Requesting the database field in custom database queries will result in an SQL error.


Affected Installations
======================

TYPO3 installations that have `sys_template` records with this flag activated,
or querying this database field in third-party extensions.


Migration
=========

Check for existing `sys_template` records having this flag activated by executing
this SQL command:

:sql:`SELECT * FROM sys_template WHERE nextLevel>0 AND deleted=0;`

before updating TYPO3 Core.

Replace the sys_template record (the uid of the record is stored in the "nextLevel" field) with a condition e.g. :ts:`[tree.level > 1]` to add TypoScript for subpages.

.. index:: Database, NotScanned
16 changes: 2 additions & 14 deletions typo3/sysext/frontend/Configuration/TCA/sys_template.php
Expand Up @@ -27,7 +27,7 @@
'searchFields' => 'title,constants,config'
],
'interface' => [
'showRecordFieldList' => 'title,clear,root,basedOn,nextLevel,sitetitle,description,hidden,starttime,endtime'
'showRecordFieldList' => 'title,clear,root,basedOn,sitetitle,description,hidden,starttime,endtime'
],
'columns' => [
'title' => [
Expand Down Expand Up @@ -123,18 +123,6 @@
'softref' => 'email[subst],url[subst]'
],
],
'nextLevel' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:sys_template.nextLevel',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'sys_template',
'size' => 1,
'maxitems' => 1,
'minitems' => 0,
'default' => '',
]
],
'include_static_file' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:sys_template.include_static_file',
'config' => [
Expand Down Expand Up @@ -229,7 +217,7 @@
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
title, sitetitle, constants, config,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:sys_template.tabs.options,
clear, root, nextLevel,
clear, root,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:sys_template.tabs.include,
includeStaticAfterBasedOn, include_static_file, basedOn, static_file_mode,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
Expand Down
Expand Up @@ -489,9 +489,6 @@
<trans-unit id="sys_template.resources">
<source>Resources</source>
</trans-unit>
<trans-unit id="sys_template.nextLevel">
<source>Template on Next Level</source>
</trans-unit>
<trans-unit id="sys_template.include_static_file">
<source>Include static (from extensions)</source>
</trans-unit>
Expand Down
Expand Up @@ -29,7 +29,6 @@ class TemplateVisibleFieldsTest extends \TYPO3\TestingFramework\Core\Functional\
'description',
'clear',
'root',
'nextLevel',
'includeStaticAfterBasedOn',
'include_static_file',
'basedOn',
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/frontend/ext_tables.sql
Expand Up @@ -82,7 +82,6 @@ CREATE TABLE sys_template (
include_static_file text,
constants text,
config text,
nextLevel varchar(5) DEFAULT '' NOT NULL,
basedOn tinytext,
includeStaticAfterBasedOn tinyint(4) unsigned DEFAULT '0' NOT NULL,
static_file_mode tinyint(4) unsigned DEFAULT '0' NOT NULL,
Expand Down
Expand Up @@ -24,9 +24,6 @@
<trans-unit id="rootline">
<source>Rootline</source>
</trans-unit>
<trans-unit id="nextLevel">
<source>Next Level</source>
</trans-unit>
<trans-unit id="templateHierarchy">
<source>Template hierarchy</source>
</trans-unit>
Expand Down
Expand Up @@ -23,7 +23,6 @@ <h2><f:translate key="{LLPrefix}templateHierarchy"/></h2>
<th><f:translate key="{LLPrefix}clearConstants"/></th>
<th><f:translate key="{LLPrefix}pid"/></th>
<th><f:translate key="{LLPrefix}rootline"/></th>
<th><f:translate key="{LLPrefix}nextLevel"/></th>
</tr>
</thead>
<f:format.raw>{hierarchy}</f:format.raw>
Expand Down

0 comments on commit dfbee19

Please sign in to comment.