Skip to content

Sort root files in withRootFiles() to keep cache hash stable - #8870

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
M-arcus:fix-root-files-cache-order
Oct 28, 2026
Merged

TomasVotruba merged 1 commit into
rectorphp:mainfrom
M-arcus:fix-root-files-cache-order

Conversation

@M-arcus

@M-arcus M-arcus commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

withRootFiles() adds the root *.php files to paths in the order Symfony Finder returns them. Finder doesn't sort, so the order is whatever the filesystem lists. On ext4 that order follows a filename hash seed per filesystem, so the same checkout can list its root files differently on another machine.

paths goes into SimpleParameterProvider::hashForCacheInvalidation(). A different order gives a different config hash, and ChangedFilesDetector then clears the whole cache. A cache restored in CI is thrown away whenever the runner's filesystem orders the root files differently.

I ran into this on GitHub Actions while two ubuntu-24.04 image versions were in rotation: every switch between them was a full run, about 150 s instead of about 30 s for roughly 1,350 files.

@TomasVotruba

Copy link
Copy Markdown
Member

Makes sense, we sort file in every other search. Thanks 👍

@TomasVotruba
TomasVotruba merged commit 80ce9c2 into rectorphp:main Oct 28, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants