Add transients size check - #217
Conversation
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe pull request adds a ChangesTransients size check
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Transients_Size
participant WP_CLI_option_list
participant WordPress_options
Transients_Size->>WP_CLI_option_list: Request autoloaded transient sizes
WP_CLI_option_list->>WordPress_options: Query transient options
WordPress_options-->>WP_CLI_option_list: Return option sizes
WP_CLI_option_list-->>Transients_Size: Return total bytes
Transients_Size-->>Transients_Size: Compare total with threshold
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds a new transients-size Doctor check to surface large autoloaded non-expiring transients separately from the existing autoloaded options size check, aligning with the behavior discussed in #150 and relying on updated filtering in wp-cli/entity-command (>= 2.8.12).
Changes:
- Introduces
WP_CLI\Doctor\Check\Transients_Sizeand registers it in the defaultdoctor.ymlconfiguration. - Updates CLI documentation/examples to include
transients-sizein the listed checks. - Adds new Behat coverage for
transients-sizescenarios and updates the default-check listing test; bumps the minimumwp-cli/entity-commanddependency to^2.8.12 || ^3.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Command.php | Updates documented “list checks” examples to include the new transients-size check. |
| src/Check/Transients_Size.php | Implements the new check by measuring total bytes of autoloaded transients via wp option list. |
| features/check.feature | Extends the “List all default checks” scenario to expect transients-size. |
| features/check-transients-size.feature | Adds Behat scenarios covering success/warning behavior and custom threshold configuration. |
| doctor.yml | Registers transients-size in the default Doctor configuration. |
| composer.json | Raises wp-cli/entity-command minimum to ^2.8.12 to depend on corrected transient filtering behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
features/check-transients-size.feature (1)
1-24: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd an exact-threshold scenario.
The scenarios cover an empty result and a result above 900 KB. Add a case where the measured autoloaded transient size equals 900 KB. Assert the status and message so a future change from
>to>=is detected.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@features/check-transients-size.feature` around lines 1 - 24, Add a scenario in the transients-size feature covering autoloaded transients measuring exactly 900 KB. Run the transients-size check and assert a success status plus the message indicating the size is less than the 900kb threshold, ensuring equality remains below the warning boundary rather than being treated as exceeding it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@features/check-transients-size.feature`:
- Around line 1-24: Add a scenario in the transients-size feature covering
autoloaded transients measuring exactly 900 KB. Run the transients-size check
and assert a success status plus the message indicating the size is less than
the 900kb threshold, ensuring equality remains below the warning boundary rather
than being treated as exceeding it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: eeb490e2-d72c-4c63-9d1d-c9d3a131beb0
📒 Files selected for processing (4)
features/check-transients-size.featuresrc/Check.phpsrc/Check/Autoload_Options_Size.phpsrc/Check/Transients_Size.php
💤 Files with no reviewable changes (2)
- src/Check/Autoload_Options_Size.php
- src/Check/Transients_Size.php
Summary
Adds a separate transients-size check for detecting large autoloaded transients.
Non-expiring transients are autoloaded by WordPress, but they are intentionally excluded from the existing autoload-options-size check. This new check reports them separately, as suggested in the issue.
The check is included in the default Doctor configuration and uses the same configurable 900 KB threshold as the existing autoloaded options check.
Implementation
The check uses wp option list with the transients, autoload and total_bytes options.
The required filtering was corrected in wp-cli/entity-command#620 and released in Entity Command v2.8.12. The minimum dependency has therefore been updated to ^2.8.12.
Testing
Fixes #150
Summary by CodeRabbit
New Features
transients-sizecheck to the default Doctor configuration.Bug Fixes
Tests