Skip to content

Fix update_unavailable_reason leaking across rows in plugin and theme list - #552

Merged
swissspidy merged 1 commit into
wp-cli:mainfrom
ekamran:shifteq/fix-update-unavailable-reason-leak
Sep 14, 2026
Merged

swissspidy merged 1 commit into
wp-cli:mainfrom
ekamran:shifteq/fix-update-unavailable-reason-leak

Conversation

@ekamran

@ekamran ekamran commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #551

The reason string was set inside the item loop when an update did not meet the PHP or WordPress requirement, but it was never reset for the next item. Every plugin or theme listed after an incompatible one then showed the first item's reason, even with update none or available.

This resets the variable for each item so only the affected row carries a reason, in both Plugin_Command::get_item_list() and the ParseThemeNameInput trait. Both sides got the same pattern from the same commit (730da5d), so the leak exists since v2.1.24.

New Behat scenarios for both sides sit next to the existing requirement scenarios: two local extensions where only the first has an incompatible update, asserting in csv output that the second row's reason stays empty. Both scenarios fail against the current main code and pass with the fix. The four existing plugin unavailable-reason scenarios and both theme requirement scenarios still pass.

Also verified on a live install: with a filter giving only the first plugin (or theme) an incompatible update, the later rows showed the leaked reason before the fix and are empty after it.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed plugin listings so unavailable update reasons are shown only for the affected plugin.
    • Fixed theme listings so unavailable update reasons do not appear on unrelated themes.
    • Ensured unaffected plugins and themes display no update-unavailability reason.

… list

The reason string was set inside the item loop when an update did not meet the PHP or WordPress requirement, but it was never reset for the next item. Every plugin or theme listed after an incompatible one then showed the first item's reason, even with update none or available.

Reset the variable for each item so only the affected row carries a reason. Covers both Plugin_Command::get_item_list() and the ParseThemeNameInput trait, which got the same pattern from the same commit.
@ekamran
ekamran requested a review from a team as a code owner September 13, 2026 11:45
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 684cb2ae-7740-4095-a960-bb005c06a6d1

📥 Commits

Reviewing files that changed from the base of the PR and between 8b288e9 and e95e969.

📒 Files selected for processing (4)
  • features/plugin.feature
  • features/theme.feature
  • src/Plugin_Command.php
  • src/WP_CLI/ParseThemeNameInput.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The plugin and theme list builders now reset update_unavailable_reason for each item. New scenarios verify that PHP requirement reasons do not appear in subsequent plugin or theme rows.

Changes

Unavailable reason scoping

Layer / File(s) Summary
Reset per-item update state
src/Plugin_Command.php, src/WP_CLI/ParseThemeNameInput.php
Each plugin and theme iteration initializes update_unavailable_reason to an empty string and assigns it directly to the output field.
Validate isolated list output
features/plugin.feature, features/theme.feature
New scenarios verify that an incompatible PHP requirement reason appears only for the affected plugin or theme in CSV output.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: swissspidy

Merge Risk: ⚪ Minimal · up to e95e9

The unavailable-update reason is now isolated to the affected plugin or theme row, with regression coverage for subsequent empty rows. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 and concisely describes the main change: fixing update_unavailable_reason values that leak between plugin and theme list rows.
Linked Issues check ✅ Passed Issue #551 requires per-row reset in Plugin_Command::get_item_list() and the ParseThemeNameInput trait. The diff resets update_unavailable_reason to an empty string at the start of each plugin a…
Out of Scope Changes check ✅ Passed The changes are limited to the two list builders and regression scenarios for the issue #551 leakage bug. The test changes directly verify the required CSV behavior. No unrelated implementation or tes…
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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.

@github-actions github-actions Bot added bug command:plugin-list Related to 'plugin list' command command:theme-list Related to 'theme list' command scope:testing Related to testing labels Sep 13, 2026
@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 3.0.1 milestone Sep 14, 2026
@swissspidy
swissspidy merged commit 2077d49 into wp-cli:main Sep 14, 2026
57 checks passed
@ekamran
ekamran deleted the shifteq/fix-update-unavailable-reason-leak branch September 14, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:plugin-list Related to 'plugin list' command command:theme-list Related to 'theme list' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_unavailable_reason from one plugin or theme leaks into later list rows

2 participants