Repository navigation
[DOCS] Document container compilation pitfalls for extended classes - #54
Merged
garbast merged 1 commit intoNov 25, 2026
Merged
Conversation
Explain why extended classes can be loaded as base classes while the DI container is compiled. Document the required service configuration and add notes on cache flushes and concurrent requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Context
This follows #53 (class loader rebuilds a proxy file removed by a concurrent cache flush). After we deployed that fix, the same TypeError showed up again in production. The main cause turned out to be something else. It is a configuration topic, so this PR documents it.
Root cause
Extender's class loader is registered only when the EventDispatcher is instantiated. That happens after the DI container exists. Container compilation runs before that point.
If the service definition of the extending class inherits
autowire/autoconfigurefrom_defaults, Symfony reflects the class during compilation (RegisterAutoconfigureAttributesPass,AutowirePass). ExcludingDomain/Modelfrom the resource scan does not help here because the tag requires an explicit definition. Reflecting the extending class makes Composer autoload the base class. From then on, that process works with the original class and none of the extending code.There is a second case. If the extended extension registers the base class as a public service, the
PhpDumperloads it while dumping the container (class lineage for preloading). EXT:events2 does this with itsEventmodel for its own tests.Consequences
Problems start when the compiling process is a frontend request that uses Extbase with the affected model.
ClassSchemaandDataMapare then built from the base class. TheDataMaplands in the shared Extbase cache, and later requests run into missing properties or this error:The compiling request itself fails with "Call to undefined method" on a method of the extending class.
Documented fixes
autowire: falseandautoconfigure: falseon its service definition.public: false,autowire: falseandautoconfigure: false.Cache flush notes
A backend flush via the Maintenance module is usually less of a problem. The editor's next backend request rebuilds the container. The timing is favorable, but nothing guarantees it.
typo3 cache:flushon the CLI leaves no container untilcache:warmuphas finished. Concurrent frontend requests compile it themselves because there is no lock. The docs now recommend running flush and warmup for the new release before switching the release symlink. They also mention the caveat about caches that contain absolute or real paths.Changes
Only
Documentation/Configuration/Index.rstis touched. The page is now split into three sections:It renders without warnings via
Build/Scripts/runTests.sh -s checkRstRenderingSingle.Verification
We tested this in a TYPO3 13.4 project with events2. Without the configuration, we did a full cache flush and then requested an event detail page. That first frontend request compiled the container and failed with HTTP 500 (undefined method of the extending class). With the configuration in place, all extended classes came from the extender proxy cache, including in the compiling process.
Extender could possibly handle this in code later (for example with a compiler pass), but this PR only documents the behaviour.
🤖 Generated with Claude Code