Restore Flight::path() autoloading broken in 3.19 - #725
Merged
Conversation
PR 709 dropped the Composer files entry for flight/autoload.php and that file returned early when vendor/autoload.php existed, so Loader::autoload() never registered. path() still added directories; namespaced app classes never loaded. Upgrades must not break that.
files autoload still registers Loader::autoload() so Flight::path() works. Composer PSR-4 already loads flight\*. Reset leftover path() dirs in AutoloadTest so LoaderTest can assert the exact list.
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.
Why
Flight::path()stopped loading namespaced app classes in 3.19.0 / 3.19.1. 3.18.3 still works. flightphp/docs hit this onapp\middleware\...after bumping core.This breaks a Flight rule: upgrades should not break the project.
Cause
PR #709 (
autoload-rework):composer.jsondropped"files": ["flight/autoload.php"], so Composer never includes the file that callsLoader::autoload().flight/autoload.phpstartedreturning whenvendor/autoload.phpexists, so a Composer install never registersLoader::loadClass().Flight::path()still callsLoader::addDirectory(). Nothing is listening.Fix
filesautoload back. Keep classmap +flight\\PSR-4.Loader::autoload(true, [dirname(__DIR__)]). Do not return early just because Composer is present.Flight::path()thenclass_exists(\app\middleware\Something::class)for a class that is not in Composer PSR-4.After merge, docs can unpin
^3.15 <3.19once there is a 3.19.2 (or whatever you tag).