perf: lazy settings sections & default value fallbacks#355
Conversation
…shim - Add type declarations to Request class methods to match PSR-7 interfaces - Fixes fatal error: Declaration of getRequestTarget() must be compatible with RequestInterface::getRequestTarget(): string - Patch adds return types and parameter types for all public methods - Compatible with PHP 7.4+ (uses PHP 7.0+ type hint features) - Automatically applied via composer patches plugin
Avoid building the full settings field structure (~307ms) on every admin page load by: 1. Adding Settings::get_setting_defaults() — a static map of all setting keys to their default values, used as a lightweight fallback in get_setting() so default_sections() doesn't need to run. 2. Adding Settings::get_section_names() — returns section slugs/titles without triggering field registration. Admin bar now uses this instead of get_sections() (2,437x faster). 3. Removing the save-default-on-register behavior in add_field() that wrote to DB every time a field was registered. 4. Adding explicit default values to ~45 wu_get_setting() call sites across 25+ files for defense-in-depth. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (30)
✨ Finishing Touches🧪 Generate unit tests (beta)✅ Unit Test PR creation complete.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Note Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
✅ Created PR with unit tests: #356 |
Merge changes from main (PRs #352 mpdf PHP8.5 compat, #355 lazy settings, #358 remove hashids dependency) and apply follow-up improvements: - Use main's mpdf-psr-http-message-shim-php8-compat.patch (proper PHP 8.5 type declarations for Request.php methods) - Fix TTL=0 handling: non-null TTL <= 0 now stores with 1s expiry (PSR-16) - Add PSR-16 key validation via validate_key() and validate_iterable() - Fix PHPStan: toggle_maintenance_mode() return type void Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Settings::get_setting_defaults()— static map of ~80 setting keys to default values, used as lightweight fallback inget_setting()sodefault_sections()doesn't run on every requestSettings::get_section_names()— returns section slugs/titles without field registration; admin bar now uses this instead ofget_sections()(2,437x faster, 0.13ms vs 307ms)add_field()— no more DB writes every time a settings field is registeredwu_get_setting()call sites across 28 files for defense-in-depthPerformance impact
get_sections)get_section_names)get_setting()fallbackdefault_sections()or returnsfalseadd_field()registrationTest plan
get_section_names()does NOT populate the$sectionscache (confirmed via reflection)🤖 Generated with Claude Code