Commit 1804e18e authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Remove deprecated ModuleTemplate->addJavaScriptCode()

Resolves: #96604
Related: #96107
Related: #91786
Change-Id: I208e320d6c7c2895bb70fc299317541d60c84131
parent 6a34e0ad
Pipeline #22351 passed with stages
in 13 minutes and 21 seconds
......@@ -47,15 +47,6 @@ class ModuleTemplate
*/
protected $docHeaderComponent;
/**
* Javascript Code Array
* Used for inline JS
*
* @var array
* @internal Only used internally, will be removed in TYPO3 v12.0
*/
protected $javascriptCodeArray = [];
/**
* Expose the pageRenderer
*
......@@ -336,31 +327,6 @@ class ModuleTemplate
}
}
/**
* Wrapper function for adding JS inline blocks
* @internal Only used internally, will be removed in TYPO3 v12.0
*/
protected function setJavaScriptCodeArray()
{
foreach ($this->javascriptCodeArray as $name => $code) {
$this->pageRenderer->addJsInlineCode($name, $code, false);
}
}
/**
* Adds JS inline blocks of code to the internal registry
*
* @param string $name Javascript code block name
* @param string $code Inline Javascript
* @return self
* @internal Not used anymore, will be removed in TYPO3 v12.0
*/
public function addJavaScriptCode($name = '', $code = ''): self
{
$this->javascriptCodeArray[$name] = $code;
return $this;
}
/**
* Get the DocHeader
*
......@@ -378,7 +344,6 @@ class ModuleTemplate
*/
public function renderContent()
{
$this->setJavaScriptCodeArray();
$this->pageRenderer->setTitle($this->title);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
......
.. include:: ../../Includes.txt
==============================================================
Breaking: #96604 - Removed ModuleTemplate->addJavaScriptCode()
==============================================================
See :issue:`96604`
Description
===========
The backend module related class method :php:`\TYPO3\CMS\Backend\Template\ModuleTemplate->addJavaScriptCode()`
has been removed.
The method allowed to add JavaScript inline code to the document
body of backend modules. This collides with `Content-Security-Policy` HTTP headers
and needs to be avoided.
The method has been marked :php:`@internal` in late TYPO3 v11 development and
has been removed in v12.
Impact
======
Calling the method in an instance triggers a fatal PHP error.
Affected Installations
======================
The extension scanner finds usage candidates as weak match. In general,
instances with extensions that come with own backend modules may be affected.
Migration
=========
There are various ways to migrate away from inline JavaScript in backend modules, a modern TYPO3 v12
solution is :doc:`JavaScript ES6 modules <Feature-96510-InfrastructureForJavaScriptModulesAndImportmaps>`.
.. index:: Backend, PHP-API, FullyScanned, ext:backend
......@@ -5113,4 +5113,11 @@ return [
'Feature-96526-PSR-14EventForModifyingPageModuleContent.rst',
],
],
'TYPO3\CMS\Backend\Template\ModuleTemplate->addJavaScriptCode' => [
'numberOfMandatoryArguments' => 0,
'maximumNumberOfArguments' => 2,
'restFiles' => [
'Breaking-96604-RemovedModuleTemplate-addJavaScriptCode.rst',
],
],
];
Markdown is supported
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