Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[4.0 P2] T-32 Cache layer robustness

Abierto
#696 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php
Área
performance

Línea de trabajo

Start in src/Instrument/ClassLoading/CachePathManager.php: loadCacheState() at :346-347, the merge loop at :347-368, and the null-cacheDir write at :397 reached by clearCacheState() at :412. Then read src/Instrument/ClassLoading/AopComposerLoader.php:160-164 and src/Instrument/Transformer/WeavingTransformer.php:970-983 for the class-map and function-proxy freshness paths. Run the existing cache path manager tests first. Done means unit tests for a merge after a concurrent write, a missing class-map file, and flushCacheState(true) without a cacheDir.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Known Issue

Part of #665 · Priority: P2 · BC window: no · References are path:line at a5a1504.

Problem

The metadata cache loses entries under concurrency, trusts files that may be missing, can write to the filesystem root, and never forgets deleted sources.

Evidence
  • src/Instrument/ClassLoading/CachePathManager.php:346-347: loadCacheState() is a no-op once the state is loaded, so flushCacheState() merges into the snapshot taken at the start of the request and overwrites entries that other processes wrote in the meantime.
  • src/Instrument/ClassLoading/AopComposerLoader.php:160-164 trusts the class map (added to Composer at :96-98). A missing cached file leads to a failed include instead of re-weaving.
  • src/Instrument/Transformer/WeavingTransformer.php:970-972: function-proxy freshness ignores everything except the file's existence. The content depends on the namespace, the advisors and PHP's internal function list, so a PHP upgrade serves stale proxies. The write at :980-983 is also non-atomic (T-05).
  • src/Instrument/ClassLoading/CachePathManager.php:343: || $force lets flushCacheState(true) run with a null cacheDir, so :397 writes to /_transformation.cache. clearCacheState() (:412) triggers this.
  • src/Instrument/ClassLoading/CachePathManager.php:347-368: entries for deleted sources are never pruned.
Failure scenario

Two concurrent cold requests both flush. The second writes its own snapshot plus its new entries, and the first request's entries are lost, so those classes re-weave on the next request.

Proposed fix
  • Re-read the file under an exclusive lock just before merging, then write through CacheFileWriter.
  • In production, check is_file on a class-map hit (cheap with the stat cache) and fall back to the loader.
  • Key function proxies by PHP_VERSION_ID plus the advisor hash.
  • Return early when cacheDir is null.
  • Prune entries whose source is gone during warmup.
Acceptance
  • Unit tests covering: a merge after a concurrent write, a missing class-map file, and flushCacheState(true) without a cacheDir.
Related

T-05, T-21.

Lenguaje dominante
PHP
Estrellas
1.7k
Forks
166
Merge medio
19 h 39 min
PR fusionados (30 d)
48

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de goaop/framework

Todos los issues de goaop/framework

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.