Review 14.3 Merged

95746[TASK] Limit global backup to stateful unit tests

Georg Ringer CR +2 V +2 Normal +223 −1 updated 09/10/26, 07:33

Commit message

The PHP unit test configuration enabled backupGlobals for the entire
suite. PHPUnit therefore serialized and restored the complete global
state before and after every test invocation, including tests that
never modify it.

A strict global-state audit of the suite found that only 110 of 731
test classes modify global state. The remaining 620 classes, covering
8,777 test invocations, paid the isolation cost without benefiting
from it.

Disable global backup by default and explicitly enable it with
attribute #[BackupGlobals(true)] the existing isolation where required
while avoiding unnecessary work for the majority of the suite.
New tests that modify global state must opt in using the same attribute.

On PHP 8.5.9, the full suite runtime improves from 24.34 seconds to
16.02 seconds, saving 8.32 seconds or 34.2 percent. A randomized run
completes in 16.80 seconds.

Normal and randomized runs execute all 11,694 tests with unchanged
results. A strict before-and-after audit reports the same 110
state-changing classes and 1,102 unique state-changing invocations,
confirming that no class requiring isolation lost its backup.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
  • Verified V +2 Done
    • Georg Ringer +2
    • core-ci +1 CI

Issues 1

Files 111

Show 91 more files

Review log 57

  1. Georg Ringer commented on patch set 1 09/09/26, 14:22

    Cherry Picked from branch main. The following files contain Git conflicts: * Build/phpunit/UnitTests.xml * typo3/sysext/adminpanel/Tests/Unit/Modules/PreviewModuleTest.php * typo3/sysext/adminpanel/Tests/Unit/Service/ConfigurationServiceTest.php * typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php * typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php * typo3/sysext/backend/Tests/Unit/Controller/SwitchUserControllerTest.php * typo3/sysext/backend/Tests/Unit/Form/Element/AbstractFormElementTest.php * typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseDefaultLanguagePageRowTest.php * typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php * typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseUserPermissionCheckTest.php * typo3/sysext/backend/Tests/Unit/Form/Processor/SelectItemProcessorTest.php * typo3/sysext/backend/Tests/Unit/LoginProvider/LoginProviderResolverTest.php * typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php * typo3/sysext/core/Tests/Unit/Core/SystemEnvironmentBuilderTest.php * typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php * typo3/sysext/core/Tests/Unit/Database/Query/QueryBuilderTest.php * typo3/sysext/core/Tests/Unit/Error/DebugExceptionHandlerTest.php * typo3/sysext/core/Tests/Unit/FormProtection/BackendFormProtectionTest.php * typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php * typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php * typo3/sysext/core/Tests/Unit/Mail/MailerTest.php * typo3/sysext/core/Tests/Unit/Mail/TransportFactoryTest.php * typo3/sysext/core/Tests/Unit/PasswordPolicy/Validator/CorePasswordValidatorTest.php * typo3/sysext/core/Tests/Unit/Resource/MetaDataAspectTest.php * typo3/sysext/core/Tests/Unit/Resource/Rendering/YouTubeRendererTest.php * typo3/sysext/core/Tests/Unit/TypoScript/AST/Visitor/AstConstantCommentVisitorTest.php * typo3/sysext/core/Tests/Unit/Utility/CommandUtilityTest.php * typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php * typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php * typo3/sysext/extbase/Tests/Unit/Mvc/Controller/MvcPropertyMappingConfigurationServiceTest.php * typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php * typo3/sysext/extensionmanager/Tests/Unit/Controller/ActionControllerTest.php * typo3/sysext/extensionmanager/Tests/Unit/Service/ExtensionManagementServiceTest.php * typo3/sysext/felogin/Tests/Unit/Validation/RedirectUrlValidatorTest.php * typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionConversionServiceTest.php * typo3/sysext/form/Tests/Unit/Service/FormEditorEnrichmentServiceTest.php * typo3/sysext/redirects/Tests/Unit/Service/RedirectServiceTest.php * typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php
  2. core-ci voted on patch set 1 V -1 09/09/26, 14:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108193

  3. Wouter Wolters uploaded patch set 2 V -1 09/09/26, 15:19

  4. Georg Ringer commented on patch set 2 09/09/26, 15:27

    This change is ready for review.
  5. core-ci voted on patch set 2 V +1 09/09/26, 15:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108199

  6. Georg Ringer voted on patch set 2 CR +2 V +2 09/10/26, 07:33

  7. Georg Ringer merged patch set 3 09/10/26, 07:33