Repository navigation
refactor(bootstrap): register the autoloader in the legacy bootstrap - #1981
Merged
Merged
Conversation
The classes this bootstrap loads depend on Composer packages and on the PSR-4 classes in src/: SmartyPage extends a Smarty class and SmartyRenderer implements a namespaced interface. Most web entry points include the bootstrap without including vendor/autoload.php first. That only worked because SmartyPage.php requires the autoloader itself and is included before the first class that needs it. Reordering the includes, or removing Smarty later, would have turned that into a fatal error on those entry points. Require the autoloader at the top of the bootstrap, so the dependency is stated where it exists. Nothing changes for current requests. The test loads the bootstrap in a separate PHP process without an autoloader, and checks that the autoloader is the first file the bootstrap includes. Assisted-by: Claude:claude-fable-5-2
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change includes focused regression coverage for Composer autoloader registration and bootstrap include order.
No open issues 🎉
What changed in this PR
This PR updates the legacy common bootstrap to register Composer’s autoloader before loading classes that depend on Composer packages and PSR-4 code, with subprocess regression coverage for bootstrap loading and include order.
Changes:
- Register Composer’s autoloader at the beginning of
lib/Common/namespace.php. - Add isolated-process tests that load the bootstrap without a pre-registered autoloader.
- Verify the autoloader is included first and dependent classes load correctly.
| File | Description |
|---|---|
| tests/lib/Common/NamespaceBootstrapTest.php | Adds subprocess tests covering bootstrap loading without an existing autoloader and verifying include order. |
| lib/Common/namespace.php | Registers Composer’s autoloader before loading the dependent legacy common classes. |
Review effort: Lite
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.
The classes this bootstrap loads depend on Composer packages and on the PSR-4 classes in src/: SmartyPage extends a Smarty class and SmartyRenderer implements a namespaced interface. Most web entry points include the bootstrap without including vendor/autoload.php first.
That only worked because SmartyPage.php requires the autoloader itself and is included before the first class that needs it. Reordering the includes, or removing Smarty later, would have turned that into a fatal error on those entry points.
Require the autoloader at the top of the bootstrap, so the dependency is stated where it exists. Nothing changes for current requests.
The test loads the bootstrap in a separate PHP process without an autoloader, and checks that the autoloader is the first file the bootstrap includes.
Assisted-by: Claude:claude-fable-5-2