Commit e4a5f3e4 authored by Anja Leichsenring's avatar Anja Leichsenring Committed by Stefan Bürk
Browse files

[TASK] Deprecate PageRenderer::removeLineBreaksFromTemplate and usages

Removal of line breaks from a rendered template can be easily achieved
by using a code optimization tool like tidy. There is no need to
have such functionality in a modern codebase.

The variable and it's usages are relics from TYPO3 4.5 and can safely
be removed, because there are better options available nowadays.

Resolves: #99685
Releases: main
Change-Id: I7018c3a022b90d08f1a88ea87d2b5622f2dfa20b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77540


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent 0079b13a
......@@ -64,6 +64,7 @@ class PageRenderer implements SingletonInterface
/**
* @var bool
* @deprecated since TYPO3 v12.2. will be removed in TYPO3 v13.0 along with enable, disable and getter method.
*/
protected $removeLineBreaksFromTemplate = false;
......@@ -709,17 +710,29 @@ class PageRenderer implements SingletonInterface
/**
* Sets removal of all line breaks in template
* @deprecated since TYPO3 v12.2. will be removed in TYPO3 v13.0.
*/
public function enableRemoveLineBreaksFromTemplate()
{
trigger_error(
'PageRenderer::enableRemoveLineBreaksFromTemplate() will be removed in TYPO3 v13.0.' .
'Use a proper output optimization tool instead.',
E_USER_DEPRECATED
);
$this->removeLineBreaksFromTemplate = true;
}
/**
* Unsets removal of all line breaks in template
* @deprecated since TYPO3 v12.2. will be removed in TYPO3 v13.0.
*/
public function disableRemoveLineBreaksFromTemplate()
{
trigger_error(
'PageRenderer::disableRemoveLineBreaksFromTemplate() will be removed in TYPO3 v13.0.' .
'Use a proper output optimization tool instead.',
E_USER_DEPRECATED
);
$this->removeLineBreaksFromTemplate = false;
}
......@@ -733,6 +746,7 @@ class PageRenderer implements SingletonInterface
$this->compressCss = false;
$this->concatenateCss = false;
$this->concatenateJavascript = false;
// @deprecated since TYPO3 v12.2. will be removed in TYPO3 v13.0 along with enable, disable and getter method, and property.
$this->removeLineBreaksFromTemplate = false;
}
......@@ -938,9 +952,15 @@ class PageRenderer implements SingletonInterface
* Gets remove of empty lines from template
*
* @return bool
* @deprecated since TYPO3 v12.2. will be removed in TYPO3 v13.0.
*/
public function getRemoveLineBreaksFromTemplate()
{
trigger_error(
'PageRenderer::getRemoveLineBreaksFromTemplate() will be removed in TYPO3 v13.0.' .
'Use a proper output optimization tool instead.',
E_USER_DEPRECATED
);
return $this->removeLineBreaksFromTemplate;
}
......@@ -2032,6 +2052,8 @@ class PageRenderer implements SingletonInterface
$templateFile = GeneralUtility::getFileAbsFileName($this->templateFile);
if (is_file($templateFile)) {
$template = (string)file_get_contents($templateFile);
// @todo remove the condition and the body with TYPO3 v13.
// @todo Belongs to Deprecation-99685-RemoveLineBreaksFromTemplate.rst
if ($this->removeLineBreaksFromTemplate) {
$template = strtr($template, [LF => '', CR => '']);
}
......
.. include:: /Includes.rst.txt
.. _deprecation-99685-1674497039:
================================================================
Deprecation: #99685 - PageRenderer::removeLineBreaksFromTemplate
================================================================
See :issue:`99685`
Description
===========
The following methods have been marked as deprecated and will be removed with TYPO3 v13:
- :php:`PageRenderer::enableRemoveLineBreaksFromTemplate()`
- :php:`PageRenderer::disableRemoveLineBreaksFromTemplate()`
- :php:`PageRenderer::getRemoveLineBreaksFromTemplate()`
The methods provide a means to remove line break characters from the rendered output,
what would reduce the size of the response. There are better options available nowadays
though and no need to rely on a static code replacement.
Impact
======
Using the methods will raise a deprecation level log entry and will stop
working with TYPO3 v13.
Affected installations
======================
Instances with extensions that call the methods are affected.
The extension scanner reports shows usages found.
Migration
=========
The methods will only remove linebreaks from the rendered HTML output, what is not
much use in terms of reducing response size. Rather migrate to a proper output
optimization tool like tidy.
All calls to the deprecated messages should simply be removed from the codebase.
.. index:: Backend, TCA, FullyScanned, ext:core
......@@ -5470,4 +5470,25 @@ return [
'Deprecation-99558-DeprecatePageRepository-getExtURL.rst',
],
],
'TYPO3\CMS\Core\Page\PageRenderer->enableRemoveLineBreaksFromTemplate' => [
'numberOfMandatoryArguments' => 0,
'maximumNumberOfArguments' => 0,
'restFiles' => [
'Deprecation-99685-RemoveLineBreaksFromTemplate.rst',
],
],
'TYPO3\CMS\Core\Page\PageRenderer->disableRemoveLineBreaksFromTemplate' => [
'numberOfMandatoryArguments' => 0,
'maximumNumberOfArguments' => 0,
'restFiles' => [
'Deprecation-99685-RemoveLineBreaksFromTemplate.rst',
],
],
'TYPO3\CMS\Core\Page\PageRenderer->getRemoveLineBreaksFromTemplate' => [
'numberOfMandatoryArguments' => 0,
'maximumNumberOfArguments' => 0,
'restFiles' => [
'Deprecation-99685-RemoveLineBreaksFromTemplate.rst',
],
],
];
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