Deprecation: #111336 - Legacy language mode and overlay type of LanguageAspect 

See forge#111336

Description 

The following methods of \TYPO3\CMS\Core\Context\LanguageAspect have been marked as deprecated and will be removed in TYPO3 v16.0:

  • LanguageAspect->getLegacyLanguageMode()
  • LanguageAspect->getLegacyOverlayType()

The same applies to the corresponding aspect properties legacyLanguageMode and legacyOverlayType , for example when accessed via $context->getPropertyFromAspect('language', 'legacyOverlayType') .

Both methods were introduced in TYPO3 v9 to map the language aspect to the former TypoScript options config.sys_language_mode and config.sys_language_overlay , which have been removed since. For a language aspect created from a site language, the legacy language mode is always 'content_fallback' , so it does not carry any information.

For the same reason, the "page not found" reason \TYPO3\CMS\Frontend\Page\PageAccessFailureReasons::LANGUAGE_NOT_AVAILABLE_STRICT_MODE ( 'language.strict' ) has been marked as deprecated and will be removed in TYPO3 v16.0. TYPO3 used it only for the legacy language mode 'strict' , which never applies to site languages, so this reason is not passed to error handlers anymore.

Impact 

Calling one of the methods, or accessing one of the aspect properties, triggers a PHP deprecation warning. The methods and properties continue to work as before until they are removed in TYPO3 v16.0.

Using the constant PageAccessFailureReasons::LANGUAGE_NOT_AVAILABLE_STRICT_MODE does not trigger a deprecation warning.

Affected installations 

TYPO3 installations with custom extensions that call LanguageAspect->getLegacyLanguageMode() or LanguageAspect->getLegacyOverlayType() , or that read the aspect properties legacyLanguageMode or legacyOverlayType .

TYPO3 installations with custom error handlers or middlewares that check for the reason PageAccessFailureReasons::LANGUAGE_NOT_AVAILABLE_STRICT_MODE .

The extension scanner reports calls of the methods as a weak match and usages of the constant as a strong match. Access to the aspect properties is not detected.

Migration 

Remove checks for PageAccessFailureReasons::LANGUAGE_NOT_AVAILABLE_STRICT_MODE . A page that is not available in the requested language and its fallback languages is reported with PageAccessFailureReasons::LANGUAGE_AND_FALLBACKS_NOT_AVAILABLE , or with PageAccessFailureReasons::LANGUAGE_NOT_AVAILABLE if the page is configured to be hidden when it is not translated.

Use LanguageAspect->getOverlayType() with the constants LanguageAspect::OVERLAYS_OFF , LanguageAspect::OVERLAYS_MIXED and LanguageAspect::OVERLAYS_ON_WITH_FLOATING instead of the legacy overlay type, and LanguageAspect->doOverlays() to check whether records are overlaid at all.

Use LanguageAspect->getFallbackChain() instead of the legacy language mode to find out which languages are used as fallback.

Before (deprecated)
if ($languageAspect->getLegacyOverlayType() === 'hideNonTranslated') {
    // ...
}
Copied!
After
use TYPO3\CMS\Core\Context\LanguageAspect;

if ($languageAspect->getOverlayType() === LanguageAspect::OVERLAYS_ON_WITH_FLOATING) {
    // ...
}
Copied!