Repository navigation
fix(cache): stop bundle-set thrash and symlink 500s in kernel cache - #38
Merged
Merged
Conversation
Cleanup dropped the oldest meta_*.json by creation time once more than 32 bundle sets existed. The mtime only changed on rebuild, so with 33+ live sets every compile evicted another live set, whose next request recompiled under LOCK_EX and evicted the next one: each request recompiled. Warm hits now refresh the metadata mtime at most hourly (skipped for a read-only prewarmed cache), and metadata beyond the cap is evicted only after 30 days without use.
resolve() skipped the trust check when <cache>/<env>/kernel was a symlink and returned it unchanged. ensureDirectory() then refused it after a full compile, so every request failed with HTTP 500. A local user able to write var/cache/<env>/ could cause that. A symlink is now untrusted like any foreign directory: the implicit path falls back to the private cache, and an explicit APP_CACHE_DIR fails early in resolve() with the existing diagnostic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
From the Fable re-audit (2026-11-22) of
sympress/kernelv1.1.17:meta_*.jsonby creation time. Every recompile evicted another live set, whose next request recompiled underLOCK_EXand evicted the next one. With 34 sets in rotation, every request recompiled.kernelin the implicit cache path (var/cache/<env>/kernel) skipped the trust check inCachePath::resolve().ensureDirectory()then refused it after a full compile, so every request failed with HTTP 500.Fix
CachePath::resolve()no longer exempts symlinks fromisTrusted(). The implicit path falls back to the private cache. An explicitAPP_CACHE_DIRwhosekernelentry is a symlink now fails inresolve()with the existing diagnostic, instead of failing later inensureDirectory().The read-only prewarmed cache behaviour (re-audit #2) and the group-writable
var/parent rule (#3) are unchanged. Both are owner decisions.Tests
BundleSetCacheTest::testMoreThanThirtyTwoLiveBundleSetsDoNotEvictEachOther: 34 live sets stay warm, and a warm hit refreshes stale metadata mtime. Fails onmain(actual size 32 matches expected size 34).CacheRequestCompatibilityTest::testSymlinkedImplicitKernelDirectoryUsesPrivateFallback: fails onmain(resolve returns the symlinked path). Passes now: the boot succeeds in the private fallback, nothing is written through the symlink, and an explicitAPP_CACHE_DIRthrows.composer qapasses: CS clean, PHPStan max clean, 112 tests, 1 FPM-only skip.composer validate --strictis valid.Release
Patch. This PR has no release commit. It ships in 1.1.18 with the follow-up PR, which carries
chore(release): prepare kernel v1.1.18.