Keep ExtensionDiscovery::sort() consistent for extensions under unknown profile directories - #1035
Keep ExtensionDiscovery::sort() consistent for extensions under unknown profile directories#1035mglaman wants to merge 1 commit into
Conversation
5bc7d7d to
a178ab7
Compare
bd2e6fc to
8c90f35
Compare
a178ab7 to
20e6baf
Compare
8c90f35 to
33d7c0f
Compare
33d7c0f to
f7189dd
Compare
…wn profile directories Extensions under a profiles/ directory that does not match a known profile left holes in the origins and profiles arrays, so array_multisort() threw a ValueError on unequal sizes. scan() filters these out before sorting, but sort() is protected and must not rely on that. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
f7189dd to
8e322eb
Compare
|
Closing without merging. This class is a copy of Review findings on this PR turned up two real quirks in our own code, neither user-visible: the profile directory list in The dead-code cleanups that were split out of this PR continue in #1042, now rebased directly onto |
Part 4 of 10 in the legacy-code audit stack (on top of #1034). Hardening in
ExtensionDiscovery::sort(), split out of the original latent-fixes PR so it can be reviewed on its own. The remaining dead-code cleanups moved to the next PR in the stack.What changed
An extension under a
profiles/directory that does not match any known profile directory fell through theelsebranch insort()without a matching entry in the$originsand$profilesarrays.array_multisort()then threwValueError: Array sizes are inconsistent. The extension now getsORIGIN_PROFILEwith no profile weight, so every key is present in both arrays.Is this reachable?
Not through
scan()today.filterByProfileDirectories()runs first and drops the same extensions using the same predicate, so users cannot hit this in practice.sort()is protected on a non-final class, though, and it should not depend on a sibling method having already filtered its input. Reviewed as hardening, not as a user-visible crash fix. No release note needed.Testing
New
ExtensionDiscoveryTestcallssort()through a subclass with an extension under an unknown profile directory. It fails onmainwith theValueErrorand passes with this change. Full suite, self-analysis, and phpcs are green.🤖 Generated with Claude Code