[6.x] Fix Migrations out of order with multiple path with certain filenames #29996
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.
For some reason, with the paths & files i'll show below, the migrations are returned out of order when the same migrations are in the
vendor/
directory (from a package) and also when they are ondatabase/migrations/
(if those same migrations are published using thevendor:publish
command).After some code sniffing, the culprit so far is the
sortBy
here.Steps To Reproduce:
The code below is to pretty much simulate what the getMigrationFiles() method does without the last part which is not necessary here, since the response in the end will be wrong too.
So this can be placed anywhere on the migrator class.
When this is ran, it will spit something like this:
As you can see, some of the migrations are out of order starting from the index
16
and1
as the vendor one is coming after the one from the app, which is wrong.I've added those empty migration "stubs" to make ensure i didn't disrupt the other tests and not cause the class already defined on path exception in some cases.
Fixes: #29964