#110100Functional tests trigger PHP warning on shutdown: Extbase ReflectionService::__destruct() writes cache too late and HashService reads missing $TYPO3_CONF_VARS
Description
Environment
- TYPO3 v13 (Composer-based install) - PHP 8.3.21 - PHPUnit 11.5.55 - Functional test context (Build/phpunit/FunctionalTests.xml)
*Problem*
Functional tests pass successfully, but when the PHP process shuts down, warnings are emitted:
PHP Warning: Undefined global variable $TYPO3_CONF_VARS in vendor/typo3/cms-core/Classes/Crypto/HashService.php on line 42 PHP Warning: Trying to access array offset on null in vendor/typo3/cms-core/Classes/Crypto/HashService.php on line 42
This happens after the test run is already finished, during PHP shutdown.
*How to reproduce*
Run a TYPO3 functional test suite, for example:
TYPO3_CONTEXT=Testing \
typo3DatabaseDriver=pdo_sqlite \
vendor/bin/phpunit -c Build/phpunit/FunctionalTests.xml <functional-test-file>
In my case, the tests complete successfully and only then the warnings appear.
*Observed behavior*
The warnings are triggered during shutdown from this call chain:
TYPO3\CMS\Extbase\Reflection\ReflectionService::__destruct() -> TYPO3\CMS\Core\Cache\Frontend\VariableFrontend->set() -> TYPO3\CMS\Core\Serializer\AuthenticatedMessageDeserializer->serialize() -> TYPO3\CMS\Core\Crypto\HashService->appendHmac() -> TYPO3\CMS\Core\Crypto\HashService->hmac()
Relevant code locations:
- vendor/typo3/cms-extbase/Classes/Reflection/ReflectionService.php:62-66 - vendor/typo3/cms-core/Classes/Cache/Frontend/VariableFrontend.php:63-66 - vendor/typo3/cms-core/Classes/Serializer/AuthenticatedMessageDeserializer.php:36-41 - vendor/typo3/cms-core/Classes/Crypto/HashService.php:42
ReflectionService::__destruct() tries to persist updated class schema cache during object destruction. That cache write is HMAC-signed, which causes HashService to access:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
At that late shutdown stage, $GLOBALS['TYPO3_CONF_VARS'] is no longer reliably available, so the warning is triggered.
*Expected behavior*
No warnings should be emitted after a successful functional test run. Cache persistence should not rely on TYPO3 globals from late destructor/shutdown context, or the relevant instances should be cleaned up before global state becomes unavailable.
*Notes*
This does not appear to be caused by install tool session shutdown handling. The actual shutdown caller is TYPO3\CMS\Extbase\Reflection\ReflectionService::__destruct() .
It looks like the underlying issue is that functional test teardown/process shutdown still allows ReflectionService to flush cache from its destructor, but by then the runtime state needed by HashService is already partially gone.
Reviews 5
- main 96068[WIP][TASK] Reproduce broken Extbase class schema cache entry
- 12.4 94723[TASK] Prevent PHPUnit warnings on ReflectionService destructor
- 14.3 94598[TASK] Prevent PHPUnit warnings on ReflectionService destructor
- 13.4 94597[TASK] Prevent PHPUnit warnings on ReflectionService destructor
- main 94505[TASK] Prevent PHPUnit warnings on ReflectionService destructor
Related issues 1
History 611
-
Simon Schaufelberger changed Related to #98124 <span data-processor="relativetime" data-value="2026-06-24T23:40:32+00:00" > 06/24/26, 23:40 </span>
-
Simon Schaufelberger changed description <span data-processor="relativetime" data-value="2026-06-24T23:41:59+00:00" > 06/24/26, 23:41 </span>
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2026-06-25T03:07:19+00:00" > 06/25/26, 03:07 </span>
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2026-06-25T03:09:53+00:00" > 06/25/26, 03:09 </span>
And discussion here: https://typo3.slack.com/archives/C03AM9R17/p1781259105863119
-
Gerrit Code Review pushed patch set 5 for main to change 94505 status
NewUnder Review <span data-processor="relativetime" data-value="2026-06-26T11:28:05+00:00" > 06/26/26, 11:28 </span> -
Gerrit Code Review pushed patch set 6 for main to change 94505 <span data-processor="relativetime" data-value="2026-06-26T11:29:11+00:00" > 06/26/26, 11:29 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 94597 <span data-processor="relativetime" data-value="2026-06-26T13:10:32+00:00" > 06/26/26, 13:10 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 94598 <span data-processor="relativetime" data-value="2026-06-26T13:10:42+00:00" > 06/26/26, 13:10 </span>
-
Garvin Hicking commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-06-26T19:25:12+00:00" > 06/26/26, 19:25 </span>Applied in changeset commit:a1703f2f54597752a74ecf3a2948bdfe7e034fb7.
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 94723 status
ResolvedUnder Review <span data-processor="relativetime" data-value="2026-07-10T10:53:07+00:00" > 07/10/26, 10:53 </span> -
Benni Mack changed status
Under ReviewClosed <span data-processor="relativetime" data-value="2026-07-29T13:21:34+00:00" > 07/29/26, 13:21 </span>
See https://review.typo3.org/c/Packages/TYPO3.CMS/+/94505