fix: harden container cache handling - #499
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens PDK container caching and path/version handling to avoid fatal errors in environments with stale caches, symlinked webroots, or restrictive open_basedir settings (as observed after WooCommerce 6.6.0).
Changes:
- Key compiled container and definition caches by an application/version-specific cache directory and cache key.
- Make
pdkVersionresilient to missing/unreadablecomposer.jsonand resolve root/config paths viarealpath()with fallbacks. - Clear compiled container cache files recursively (including nested version directories) and invalidate OPcache entries for deleted PHP files.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Facade/PdkTest.php | Updates/extends unit tests to cover versioned cache directories, recursive clearing, and pdkVersion fallback. |
| tests/Hook/ClearContainerCacheHook.php | Ensures test runs start with a clean cache by recursively deleting .cache contents. |
| src/Base/PdkBootstrapper.php | Passes the app/plugin version into PdkFactory to version cache keys/paths. |
| src/Base/Pdk.php | Reworks cache clearing to recursively delete compiled container/proxy caches and invalidate OPcache. |
| src/Base/Factory/PdkFactory.php | Introduces cache versioning to isolate compilation/proxy output and definition cache keys per version. |
| config/pdk-dependencies.php | Makes pdkVersion non-fatal by returning 'unknown' when composer.json can’t be read. |
| config/pdk-default.php | Resolves rootDir/configDirs via realpath() (with fallbacks) to avoid symlink-based paths in compiled artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #499 +/- ##
============================================
+ Coverage 94.22% 94.25% +0.02%
- Complexity 2332 2350 +18
============================================
Files 350 350
Lines 7499 7538 +39
============================================
+ Hits 7066 7105 +39
Misses 433 433 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fb14944 to
0d907a1
Compare
d3f0681 to
0306f68
Compare
0306f68 to
b8bbe44
Compare
|
🎉 This PR is included in version 4.2.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This addresses failures seen after the WooCommerce 6.6.0 release where stale container/cache state or symlinked webroots with
open_basedirrestrictions could cause fatal errors.realpath()with fallbackspdkVersionlookup from failing the application whencomposer.jsoncannot be readTrade-offs
INT-1709