Deprecation: #95326 - Various “getInstance()” static methods on Singleton interfaces

See Issue #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.

Migration

Check TYPO3’s “Extension Scanner” in the Install Tool if you’re affected and replace with constructor injection via Dependency Injection if possible, or use GeneralUtility::makeInstance() instead.