t3ext-oidc icon indicating copy to clipboard operation
t3ext-oidc copied to clipboard

[BUGFIX] Deal with non-public internal TYPO3 services

Open sbuerk opened this issue 2 months ago • 1 comments

TYPO3 v13 requires some services to create frontend environment which are not made public by the core, mainly because they are injected and due to the @internal flag no need to do it so.

To understand the strategy used in this change it's important to know in which steps the DI container is created in TYPO3, which is literally following:

  • ServiceProvider for lowlevel/failsafe container to make services available also in EXT:install context. This is not documented and communicated, considered mainly for TYPO3 internal usage. This provides factories and extension available in failsafe and not failsave container context and everything below only for non-failsafe context.

  • Iterate over Configuration/Services.yaml files from TYPO3 extensions, and based on the provided resources first respect and configurate definitions based on php attributes and manually based on entries in the file.

  • Iterate over Configuration/Services.php files from TYPO3 extensions, and based on eventually included resource path load definitions scan PHP attributes again to estend/replace service definitions and directly added definitions. As this is executed code conditional registrations can be done using PHP functionalites, for example using class_exist() checks.

This change uses following strategies to prepare the frontend simulation for dependency injection while keeping it compatible with multiple TYPO3 versions:

  • Adding #[Exclude] to the TYPO3 version depending implementation to keep them included.

  • Introdcing the Configuration/Services.php file to make version based conditional service configuration possible:

    • Allow autoconfiguration and autowiring only for the Frontend Simulation class suitable for the current installed TYPO3 version and make it public retrieveable from the DI container, for example using GeneralUtility::makeInstance().

    • Set an alias for the FrontendSimulationInterface to the version related implementation service and make it public instanciable, which allows to use the interface for constructor or inject-method dependency injection in the future and allow to retrieve it using

      $frontendSimulation = GeneralUtility::makeInstance(
        FrontendSimulationInterface::class
      );
      
    • Reconfigure the definition for TYPO3 v13 services only on v13 using class_exist() checks to make them public retrieveable.

    • FrontendSimulationv13 no longer extends the FrontendSimulationv12 class and implements the interface now, which required that method cleanupTSFE() has been cloned and unsetting the TYPO3 v12 typoscript context aspect removed.

    • FrontendSimulationv12::cleanupTSFE() has been modified and the TYPO3 v13 frontend.preview context is no longer unset.

    • AuthenticationService::getFrontendSimulation() has been streamlined to use the FrontendSimulationInterface to retrieve the suitable implementation for current TYPO3 versions allowing to remove TYPO3 Version related code here and some use import statements.

Resolves: #231

sbuerk avatar Nov 06 '25 15:11 sbuerk

Thanks for your work. Since I failed to reproduce the bug, I still wait for better feedback on how to reproduce the issue.

liayn avatar Nov 11 '25 08:11 liayn