`PREBUILT_CACHE` weaves and writes the cache when a class is missing from it (fails on read-only file systems)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- PHP
- スター
- 1.7k
- フォーク
- 166
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 42
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goaop/framework のほかの issue
-
Enhancement Performance
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
Enhancement Performance To Be Discussed
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
goaop/framework#814 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6 To Be Discussed
難易度 4/5 1週間以上 初心者へのやさしさ 8/100
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
goaop/framework の issue をすべて見る
似ている issue
-
Administration: required plugin configuration field stays invalid after restoring its saved valueオープンneeds-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
good first issue priority:low type:docs
難易度 1/5 1〜3時間 初心者へのやさしさ 95/100
crazy-goat/rabbit-stream#969 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
opensourcepos/opensourcepos#4801 ·
メンテナーはふだん 1 日以内に返信
-
backend docs
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
Open-Locker/Open-Locker#368 ·
メンテナーはふだん 1 日以内に返信
-
enhancement priority Sales
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
novalo-dev/Prestashop-MCP-Server#190 ·
メンテナーはふだん 1 日以内に返信