Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Deprecation
Introduction
Calls to deprecated functions are logged to track usage of deprecated/outdated methods in the TYPO3 Core. Developers have to make sure to adjust their code to avoid using this old functionality since deprecated methods will be removed in future TYPO3 releases.
Deprecations use the PHP method trigger_
and run through the logging and exception stack of the TYPO3 Core. There are
several methods that help extension developers in dispatching deprecation
errors. In the development context, deprecations are turned into exceptions by
default and ignored in the production context.
Note
For information how to handle deprecations in the TYPO3 Core, see the Contribution Guide: How to deprecate classes, methods, arguments and hooks in the TYPO3 core.
Enabling deprecation errors
TYPO3 ships with a default configuration, in which deprecation logging is disabled. If you upgrade to the latest TYPO3 version, you need to change your development configuration to enable deprecation logging in case you need it.
Via GUI
Enabling the deprecation log can be done in the Admin Tools > Settings backend module. Click on Choose Preset in the Configuration Presets pane, open Debug settings, activate the Debug option and submit with Activate preset. Disabling the deprecation log can be done by selecting the Live preset instead.
The debug preset enables also some other debug settings.
Note
These steps only enable/disable the FileWriter,
which comes with the TYPO3 default configuration. If you manually configured
additional writers for the TYPO3.
logger, you need to
manually remove them to completely disable deprecation logging.
Via configuration file directly
Instead of using the GUI you can also enable
or disable the deprecation log with the disabled
option:
<?php
return [
// ... some configuration
'LOG' => [
'TYPO3' => [
'CMS' => [
'deprecations' => [
'writerConfiguration' => [
'notice' => [
'TYPO3\CMS\Core\Log\Writer\FileWriter' => [
'disabled' => false,
],
],
],
],
],
],
],
// ... more configuration
];
Deprecation logging can also be enabled in the additional.
configuration file, here with safeguarding to only enable it in
development context:
<?php
use Psr\Log\LogLevel;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Log\Writer\FileWriter;
if (Environment::getContext()->isDevelopment()) {
$GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['deprecations']
['writerConfiguration'][LogLevel::NOTICE][FileWriter::class]
['disabled'] = false;
}
For more information on how to configure the writing of deprecation logs see Writer configuration.
Find calls to deprecated functions
The extension scanner provides an interactive interface to scan extension code for usage of removed or deprecated TYPO3 Core API.
It is also possible to do a file search for @deprecated
and
E_
. Using an IDE you can find all calls to the affected
methods.
The deprecations are also listed in the changelog of the corresponding TYPO3 version.
Deprecate functions in extensions
Methods that will be removed in future versions of your extension should be marked as deprecated by both the doc comment and a call to the PHP error method:
/**
* @deprecated since version 3.0.4, will be removed in version 4.0.0
*/
public function decreaseColPosCountByRecord(array $record, int $dec = 1): int
{
trigger_error(
'Method "decreaseColPosCountByRecord" is deprecated since version 3.0.4, will be removed in version 4.0.0',
E_USER_DEPRECATED
);
// ... more logic
}
For more information about how to deprecate classes, arguments and hooks and how the TYPO3 Core handles deprecations, see How to deprecate classes, methods, arguments and hooks in the TYPO3 core.