Skip to content

Add transients size check - #217

Open
ekamran wants to merge 3 commits into
wp-cli:mainfrom
ekamran:fix/transients-size
Open

Add transients size check#217
ekamran wants to merge 3 commits into
wp-cli:mainfrom
ekamran:fix/transients-size

Conversation

@ekamran

@ekamran ekamran commented Aug 3, 2026

Copy link
Copy Markdown

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

  • Composer validation
  • PHP lint
  • PHPCS
  • PHPStan
  • PHPUnit
  • Focused Behat scenarios with SQLite and MySQL 8
  • Full Doctor Command Behat suite with SQLite
  • Manual testing against WordPress with MySQL 8

Fixes #150

Summary by CodeRabbit

  • New Features

    • Added a transients-size check to the default Doctor configuration.
    • Reports whether autoloaded transient data exceeds the recommended 900 KB threshold, with readable size information and configurable limits.
    • Excludes expiring transients from the measurement.
    • Added the check to Doctor command documentation and available check listings.
  • Tests

    • Added coverage for success, warning, exclusions, and custom threshold scenarios.

@ekamran
ekamran requested a review from a team as a code owner August 3, 2026 20:16
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

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:123

You can find a list of all available Behat steps in our handbook.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dca0a1ba-8e69-4ccd-847c-7a248eae480f

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3b086 and 70ad1fd.

📒 Files selected for processing (1)
  • composer.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • composer.json

📝 Walkthrough

Walkthrough

The pull request adds a transients-size doctor check. It measures autoloaded transient sizes, applies configurable thresholds, registers the check, updates documentation, and adds end-to-end coverage.

Changes

Transients size check

Layer / File(s) Summary
Implement transient size measurement
src/Check/Transients_Size.php, composer.json
Adds the Transients_Size check. It measures autoloaded transient bytes, compares them with a configurable 900 KB threshold, and formats the result.
Register and document the check
doctor.yml, src/Command.php
Adds transients-size to the default configuration and documented check listings.
Validate thresholds and exclusions
features/check-transients-size.feature, features/check.feature
Adds coverage for success, warning, exclusion, custom-threshold, description, and default-list behavior.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR detects autoloaded transients separately but does not include them in autoload-options-size as required by issue #150. Update autoload-options-size to include non-expiring autoloaded transients, or document approval for the separate-check behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: adding a transients-size check.
Out of Scope Changes check ✅ Passed The dependency, configuration, documentation, implementation, and tests directly support the transients-size check and issue #150.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Check/Transients_Size.php 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoload-options-size check should include autoloaded transients

1 participant