`PREBUILT_CACHE` weaves and writes the cache when a class is missing from it (fails on read-only file systems)
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Read src/Instrument/ClassLoading/SourceTransformingLoader.php around saveToCache() and src/Instrument/ClassLoading/CachePathManager.php around flushCacheState(), then inspect the existing cache tests. First decide how PREBUILT_CACHE should handle cache misses and missing cached files; done means the chosen behavior avoids the reported write or warning, the documentation matches, and the acceptance tests pass. An open linked pull request is already addressing this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found while benchmarking with goaop/shop-demo (PHP 8.5.12, framework b755e57). Follow-up of #680, which fixed the same promise for the advisor caches only.
Problem
Features::PREBUILT_CACHE is documented as "never writes to the cache directory … Works on read-only file systems" (docs/configuration.md:37, src/Aop/Features.php). A class below the include paths that is missing from the cache is nevertheless woven by the request that loads it, and the result is written:
SourceTransformingLoader::saveToCache()writes the woven source with noPREBUILT_CACHEguard (src/Instrument/ClassLoading/SourceTransformingLoader.php:311-346, write at:333);CachePathManager::flushCacheState()rewrites both metadata files at shutdown; it is guarded byis_writable($this->cacheDir)only (src/Instrument/ClassLoading/CachePathManager.php:616).
On a read-only file system, CacheFileWriter::write() throws WeavingException::cacheDirectoryNotCreated / cacheFileNotWritten (src/Core/Cache/CacheFileWriter.php:61,76), so the request fails (from reading the code; not reproducible as root here).
Reproduction (writable cache)
cd shop-demo
APP_MODE=prebuilt vendor/bin/aspect cache:warmup:aop config/bootstrap.php
# add an advised class after the warm-up, e.g. src/Service/LateService.php (matched by
# MonitoringAspect's execution(public App\Service\*->*(*))), then load it with APP_MODE=prebuilt
Result: the request loads the parser, the transformers, the matcher and the aspects (234 files included for a script that only boots the kernel and creates this one object), writes var/cache/prebuilt/src/Service/LateService.php and LateServiceOriginalTrait.php, and rewrites _include.cache.
Related variant: when a record exists but its cached file is gone, PREBUILT_CACHE trusts the record, file_get_contents() of the missing file raises a warning (SourceTransformingLoader.php:298), and the class is woven and written again.
Proposal (decide which)
- Serve without saving: with
PREBUILT_CACHE, a miss is woven and the woven source is emitted by the stream filter as usual, but nothing is written and nothing is flushed. The behaviour stays correct, the file system stays untouched, and each such request pays for weaving. - Fail fast: throw a dedicated
WeavingException(seesrc/Aop/Exception/AGENTS.md) that names the class and says to rebuild the cache withcache:warmup:aop.
Option 1 matches the documented contract; option 2 surfaces an incomplete deployment immediately. Either way, the missing-cached-file variant should take the same path instead of raising a warning.
Acceptance
- With
PREBUILT_CACHE, a miss writes nothing: tested on a read-only vfs and on real disk. docs/configuration.mdmatches the behaviour.composer test,composer analyze.
Estimate
Medium: SourceTransformingLoader::saveToCache() and CachePathManager::flushCacheState() guards, plus a decision on the semantics and tests.
Generated by Claude Code
- Lingua principale
- PHP
- Stelle
- 1.7k
- Fork
- 166
- Merge medio
- 1g 1h
- PR unite (30g)
- 42
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di goaop/framework
-
Enhancement Performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance To Be Discussed
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
goaop/framework#814 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement PHP-8.6
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement PHP-8.6 To Be Discussed
Difficoltà 4/5 Più di una settimana Idoneità per principianti 8/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement PHP-8.6
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di goaop/framework
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Automattic/blocks-engine#4621 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
YunoHost-Apps/snappymail_ynh#205 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Automattic/static-site-importer#2653 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug (unconfirmed) Search :mag:
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
FreshRSS/FreshRSS#9533 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
ExpressionEngine/ExpressionEngine#5453 ·
I maintainer di solito rispondono entro 1 giorno