Repository navigation
Conversation
A concurrent cache flush may delete the proxy file between has() and requireOnce(). Composer then silently loads the base class without the extending classes. Rebuild the entry if requireOnce() returns false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
sfroemkenjw
force-pushed
the
bugfix/rebuild-proxy-after-concurrent-flush
branch
from
November 24, 2026 06:51
ed1a9d1 to
80bec12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ClassLoader::loadClass()checks the cache entry withhas()and then callsrequireOnce():SimpleFileBackend::requireOnce()returnsfalseif the file is missing. A concurrent cache flush (cache:flush, a deployment or "Flush all caches") can remove the proxy file afterhas()and beforerequireOnce(). When that happens the class stays undefined, butloadClass()still returnstrue. PHP then moves on to the Composer autoloader, which loads the plain base class without the extending classes. No error is raised.Why 11.1.4 does not cover this
11.1.4 (7912da2) flushes the Extbase cache after building proxy classes. That only helps if the rebuild happens after the broken DataMap was written. With parallel requests the order is often the other way round:
has()returns true. A concurrent flush removes the proxy file.requireOnce()returns false, so Composer loads the baseLocationmodel without the extending propertyfacility(?Facility).ClassCacheManager::addFileToCache()flushes the Extbase cache.Locationfrom the base class, sofacilitygetsRelation::HAS_NONE.DataMapFactory::buildDataMap()writes this DataMap to the shared Extbase cache right away.ReflectionService::__destruct(), where the last writer wins. That entry is built from the correct proxy class, which includesfacility.From step 5 on,
DataMapper::getEmptyRelationValue()maps an emptyfacilityto[]instead ofnull:The error stays until the Extbase cache is flushed again. We ran into this in production right after a
cache:flushunder live traffic (TYPO3 13.4, EXT:events2 with extending models, Extbase cache on the file backend).How to reproduce
The real window is only a few microseconds wide, so the order of events has to be forced:
?Facility).ClassLoader::loadClass(), remove the proxy cache entry right beforerequireOnce().Fix
If
requireOnce()returnsfalse, build the entry again and require it:Through the existing 11.1.4 behaviour, the rebuild also flushes the Extbase cache before this request builds its DataMap. We forced the same order of events against the patched version: the DataMap is correct and no error occurs.
Tests
Tests/Functional/Loader/ClassLoaderTest::loadClassRebuildsCacheEntryRemovedByConcurrentFlush.requireOnce()returnsfalsefirst andtruesecond, andbuild()must be called exactly once.loadClasstest now also asserts thatbuild()is never called when the entry exists.All 39 functional tests pass. php-cs-fixer and PHPStan pass as well.
🤖 Generated with Claude Code