#110274Class loading information registration drops PSR-4 paths
Description
When class loading information is generated and registered for extensions
(“classic mode”, and functional tests, whose instances always run in classic
mode), PSR-4 namespace prefixes are handled destructively: a prefix used by more
than one package keeps only the directories of the last package processed. All
other directories registered for that prefix are silently dropped, and the
classes below them are no longer autoloadable.
Two independent places cause this.
1. Registration overwrites what the Composer class loader already knows
“ClassLoadingInformation::registerClassLoadingInformation()” applies the dumped
PSR-4 information by calling “setPsr4()” on the Composer class loader, once per
prefix. That method is a hard assignment: it replaces all directories currently
registered for the prefix instead of adding to them.
The dumped information only knows the active extension packages. Every
non-extension package that shares the prefix — a library shipped as its own
Composer package, for example — therefore loses its directory the moment the
information is registered.
The same applies to
“ClassLoadingInformation::registerTransientClassLoadingInformationForPackage()”,
which is used when an extension is activated at runtime.
2. The generator merges the per package information destructively
“ClassLoadingInformationGenerator::buildAutoloadInformationFiles()” accumulates
the per package PSR-4 information with “array_merge()”. That function overwrites
string keys, so two active extensions declaring the same PSR-4 prefix clobber
each other already while the dump is written — independent of the Composer class
loader, in any classic mode installation.
How to reproduce
Reported downstream as TYPO3/testing-framework#667“Library classes not found in extensions with shared autoload prefix”).
An extension that ships a framework agnostic library under the same namespace is
the common real world trigger:
- library package “acme/example”, PSR-4 prefix “Acme\Example” pointing to “src”
- TYPO3 extension “acme/typo3-example”, PSR-4 prefix “Acme\Example” pointing to
“Classes”, requiring “acme/example”
Composer registers both directories for the prefix. The class loading
information dumped for the test instance carries the extension directory only.
After the dumped information has been registered, the library directory is gone
and every class of “acme/example” fails with “Class not found”.
Verified with a minimal reproduction — two Composer packages with one class
each, plus a single functional test that only asserts that both classes exist —
against TYPO3 v14.3.5 and PHP 8.5.
A regular Composer mode installation is not affected: the dump is skipped there
entirely and the Composer class loader stays authoritative. Functional tests are
affected because the testing framework runs its instance in classic mode on top
of the live Composer class loader, which is what makes this primarily, but not
exclusively, a testing problem.
Proposed fix
Both places have to accumulate instead of replace, with the extension
directories keeping precedence and everything else preserved as fallback:
- Registration: merge the dumped directories in front of the directories already
registered for the prefix, de-duplicated, so that repeated registration stays
idempotent. Functional tests re-bootstrap per test and would otherwise grow
the list on every boot. - Generator: accumulate per prefix instead of merging the whole array.
Verified against the reproduction: with the change both the extension classes
and the library classes load, including across the repeated bootstrap that a
frontend sub request performs.
Affected branches
The two code places are identical in main, 14.3 and 13.4, so all three branches
are affected.
Reviews 3
History 36
-
Stefan Bürk changed category assigned to Stefan Bürk <span data-processor="relativetime" data-value="2026-07-23T11:12:39+00:00" > 07/23/26, 11:12 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 94901 status
NewUnder Review <span data-processor="relativetime" data-value="2026-07-23T11:22:35+00:00" > 07/23/26, 11:22 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 94907 <span data-processor="relativetime" data-value="2026-07-23T13:10:27+00:00" > 07/23/26, 13:10 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 94908 <span data-processor="relativetime" data-value="2026-07-23T13:22:00+00:00" > 07/23/26, 13:22 </span>
-
Stefan Bürk commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-07-23T13:45:10+00:00" > 07/23/26, 13:45 </span> -
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-08-11T08:51:54+00:00" > 08/11/26, 08:51 </span>
Applied in changeset commit:3c6390b797aaff2e5fca149d1df8bcb29c96a948.