Make the class-loader cache build-time and add a loader debug page#35
Open
darylldoyle wants to merge 2 commits into
Open
Make the class-loader cache build-time and add a loader debug page#35darylldoyle wants to merge 2 commits into
darylldoyle wants to merge 2 commits into
Conversation
Class-loader cache (breaking — targets a major release): - Runtime is now read-only. ModuleInitialization reads a pre-built cache if present and discovers live otherwise; it never writes the cache, removing the stale-cache failure mode from #30. - Caching is opt-in, produced at build time via a shipped `vendor/bin/tenup-framework-generate-class-cache` command (no WordPress required) and a `composer generate-class-cache` alias in this repo. - Removed should_use_cache(), the production/staging gating, and VIP_GO_APP_ENVIRONMENT handling. TENUP_FRAMEWORK_DISABLE_CLASS_CACHE now forces live discovery. Cache filename bumped to class-loader-cache-v2.php so caches written by 1.x are ignored after upgrade rather than served stale. Loader debug page: - Hidden, admin-only page (admin.php?page=tenup-framework-loaders, manage_options) aggregating every loader cache across all framework copies via the tenup_framework_debug_loaders filter, with an on-demand live-vs-cache staleness check. Recording and the page are gated behind is_admin() so the front end pays nothing. Read-only; disable via the tenup_framework_enable_loader_debug filter or the TENUP_FRAMEWORK_DISABLE_LOADER_DEBUG constant. Docs and tests: - New docs: Build-and-Deployment, Debugging, Upgrade-Guide. Rewrote the cache sections of Autoloading and Modules-and-Initialization. - Tests cover the read-only driver, generate/read paths, admin vs front-end dispatch, the debug registry/page, and the staleness diff. phpcs, phpstan (level 10) and phpunit all green. Refs #30
- Card per loader with a colour-coded status badge (in use / uncached / disabled / present-but-unused) and an explanatory notice. - Move the loaded class list into a collapsible <details> accordion so a long list no longer makes the page huge. - Surface uncached as a noticeable amber state (valid default, not an error); reserve red for genuine problems (present-but-unused, stale, legacy files). - Self-contained scoped styles using the WP admin palette.
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.
Summary
Reworks the class-loader cache so it is generated at build time and only ever read at
runtime, and adds a hidden admin page for inspecting loader caches on a running site.
Closes #30.
Screenshots
Loader debug page —
admin.php?page=tenup-framework-loaders:The runtime no longer generates the cache automatically. On 1.x the first
production/staging request wrote the cache and later requests read it forever — the
stale-cache bug behind #30. Now the framework reads a pre-built cache if present and
discovers live otherwise; it never writes. Caching becomes opt-in via a build step.
Existing installs that upgrade without adding the build step keep working but run
uncached. See the new Upgrade Guide.
Removed:
should_use_cache(), the production/staging gating, andVIP_GO_APP_ENVIRONMENThandling.
TENUP_FRAMEWORK_DISABLE_CLASS_CACHEnow means "ignore any shipped cache anddiscover live." Cache filename bumped to
class-loader-cache-v2.phpso 1.x caches areignored after upgrade.
What's included
Build-time cache
ReadOnlyFileDiscoverCacheDriver— read-only Spatie driver (no-op writes, nomkdir).ModuleInitialization::generate_cache()plusbin/tenup-framework-generate-class-cache(runs without bootstrapping WordPress) and a
composer generate-class-cachealias.Loader debug page
admin.php?page=tenup-framework-loaders(manage_options).tenup_framework_debug_loadersfilter (works across php-scoped / multi-version copies).a collapsible list of loaded classes (with resolved files), and an on-demand
live-vs-cache staleness check.
is_admin(), so the front end loads none of it.Read-only; disable via
tenup_framework_enable_loader_debug/TENUP_FRAMEWORK_DISABLE_LOADER_DEBUG.Docs
Build-and-Deployment.md(CLI + GitHub Actions/GitLab CI/CircleCI examples + per-packagemodel),
Debugging.md,Upgrade-Guide.md.Autoloading.mdandModules-and-Initialization.md.Testing
composer lint(PHPCS 10up),composer static(PHPStan level 10), andcomposer test(37 tests) all pass.
the debug registry/page, and the staleness diff.