Deprecation: #95326 - Various "getInstance()" static methods on singleton interfaces¶
See forge#95326
Description¶
A few classes within TYPO3 Core have a static method getInstance()
which acts as a wrapper for the constructor which originally was meant as
a performance improvement as pseudo-singleton concept in TYPO3 v6.
With dependency injection, these classes can be injected or instantiated directly without any performance penalties.
Therefore the following methods have been marked as deprecated:
TYPO3\CMS\Core\Resource\Index\ExtractorRegistry::getInstance()
TYPO3\CMS\Core\Resource\Index\FileIndexRepository::getInstance()
TYPO3\CMS\Core\Resource\Index\MetaDataRepository::getInstance()
TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry::getInstance()
TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::getInstance()
TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorRegistry::getInstance()
TYPO3\CMS\Form\Service\TranslationService::getInstance()
TYPO3\CMS\T3editor\Registry\AddonRegistry::getInstance()
TYPO3\CMS\T3editor\Registry\ModeRegistry::getInstance()
Impact¶
Calling the methods directly in third-party PHP code will trigger a PHP
E_USER_DEPRECATED
error.
Affected Installations¶
Any TYPO3 installation with custom PHP code calling the methods are affected.
Migration¶
Check Admin Tools > Upgrade > Scan Extension Files if your
installation is affected and replace calls with constructor injections via
dependency injection if possible, or use
GeneralUtility::makeInstance()
instead.