Cache keys are hashed absolute paths, so the cache can never be reused across checkouts (CI → local, git worktrees)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start with ChangedFilesDetector, especially getFilePathCacheKey() and resolvePath(), then trace how cache entries are written and read. Decide how the project root is supplied and how paths outside it behave, using the issue's PHPStan comparison as context. Done means cache entries can be reused across equivalent checkouts without breaking existing cache reads.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
| Subject | Details |
|---|---|
| Rector version | 2.6.6 |
| Installed as | composer dependency |
ChangedFilesDetector keys every cache entry on the absolute path of the file:
private function getFilePathCacheKey(string $filePath): string
{
return $this->fileHasher->hash($this->resolvePath($filePath) . $this->scopeSuffix);
}
private function resolvePath(string $filePath): string
{
$realPath = realpath($filePath);
// ...
return $realPath;
}
The path is hashed into the cache file's name, so the cache is bound to one location on disk. Move the project - a second git worktree, a CI checkout, a container mount - and the cache is 100% misses while containing nothing that could be rewritten to fix it.
Measurements
A 12 762-file project, 14 cores, PHP 8.5.10.
| Scenario | Wall time |
|---|---|
| fresh checkout, empty cache | 224 s |
| same checkout, warm cache | 5 s |
| fresh checkout, cache copied from another checkout of the same commit | 247 s (291 MB copied for nothing) |
For comparison, the same experiment with the other two tools in the same toolchain, copying their caches into the same fresh checkout:
| Tool | cold | seeded from another checkout |
|---|---|---|
| Pint (PHP-CS-Fixer) | 105 s | 2.7 s |
| PHPStan | 43 s | 4.4 s |
| Rector | 224 s | 247 s |
Rector's cache records nothing about the environment. Grepping all 12 761 entries of a populated tmp/rector finds zero references to a PHP version, an extension list or an OS - each entry is just a content hash. The absolute path is the only thing standing between that cache and reuse somewhere else.
Proposal
Key on the path relative to the project root and re-absolutize on read, as PHPStan does.
Two honest caveats:
- Existing caches invalidate once on upgrade.
- Files outside the project root (if any can reach the detector) need a defined behaviour - PHPStan's transformer leaves an already-absolute path untouched, which also keeps old-format caches readable.
I am happy to send a PR if you agree with the direction. I would rather hear which shape you want (anchor directory as a constructor dependency vs resolving it from the config) than guess and have it rewritten.
- Lenguaje dominante
- PHP
- Estrellas
- 137
- Forks
- 451
- Merge medio
- 7 h 11 min
- PR fusionados (30 d)
- 129
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rectorphp/rector-src
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
rectorphp/rector-src#8494 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
rectorphp/rector-src#8493 ·
Todos los issues de rectorphp/rector-src
Issues similares
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Automattic/blocks-engine#2161 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/static-site-importer#1824 ·
-
[Chore] Keep one viget-block-generator skill and replicate it, instead of four tracked copies Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Cannot reset column width Abierto0. Needs triage bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100