Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[4.0 P2] T-32 Cache layer robustness

Aperta
#696 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
performance

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
1.7k
Fork
166
Merge medio
9h 24m
PR unite (30g)
29

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di goaop/framework

Tutte le issue di goaop/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.