Skip to content

Report an error when the autoload value cannot be stored - #696

Merged
swissspidy merged 1 commit into
mainfrom
fix/set-autoload-update-error
Nov 25, 2026
Merged

swissspidy merged 1 commit into
mainfrom
fix/set-autoload-update-error

Conversation

@swissspidy

@swissspidy swissspidy commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #689, from a CodeRabbit "outside diff range" finding on that PR that came in after it was merged.

set_autoload() ignored the result of $wpdb->update(), so when the database rejected the write (read-only replica, lost connection, etc.) wp option set-autoload still printed "Success: Updated autoload value…" and exited 0. Since #689, wp option update --autoload=… with an unchanged value goes through the same code.

It now errors with Could not update autoload value for '<option>' option. before touching the caches.

The new scenario makes only that UPDATE fail (a mu-plugin rewrites it via the query filter) and covers both wp option update and wp option set-autoload. It fails without the fix (success message, exit 0) and passes with it. option.feature and option-set-autoload.feature pass locally (MariaDB, WordPress 7.1.5); the scenario was also checked on WordPress 6.5 and SQLite.

The other outside-diff finding (the cache being written back instead of deleted, a small race with persistent object caches) overlaps with #688, so it's left for after that lands.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Option autoload changes now report an error when the database update fails, rather than reporting success. Both supported commands return a failure status in this case.

set_autoload() ignored the result of $wpdb->update(), so a failed query
still printed success. It is now also reached from `wp option update`
when only the autoload value changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWTd5pwpi2xQfDA6mUYkkx
@swissspidy
swissspidy requested a review from a team as a code owner November 25, 2026 12:24
Copilot AI balanced review requested due to automatic review settings November 25, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

set_autoload() now reports an error when the database update returns false. A feature scenario checks this behavior for both wp option update and wp option set-autoload.

Changes: Autoload update failure handling

Layer / File(s) Summary
Check and test the update result
src/Option_Command.php, features/option.feature
set_autoload() reports an error and stops before cache refresh and success output when $wpdb->update() returns false. The scenario checks both commands for an error on STDERR, no success output on STDOUT, and exit code 1.

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

Change: Bug fix

Possibly related PRs

Suggested reviewers: danielbachhuber, ernilambar, schlessera

Merge Risk: Minimal · up to 898c3

The change makes wp option set-autoload and wp option update --autoload=… report an error and exit non-zero when the database write fails, instead of reporting success. A new feature scenario covers both commands. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: when the autoload value cannot be stored, wp option set-autoload and wp option update --autoload now report an error. The raw summary shows set_autoload() checks the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: when the autoload value cannot be stored, wp option set-autoload and wp option update --autoload now report an error. The raw summary shows set_autoload() checks the $wpdb->update() result and stops with an error on failure, and the objectives describe the same fix. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 059f582d-55ab-4e07-885b-7469238bbbc1
Commits

Reviewing files that changed from the base of the PR and between 899fb2c and 898c321.

Files selected for processing: 2

  • features/option.feature
  • src/Option_Command.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@github-actions github-actions Bot added bug command:option-update Related to 'option update' command command:option-set-autoload Related to 'option set-autoload' command labels Nov 25, 2026
@codecov

codecov Bot commented Nov 25, 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 merged commit 0e4da23 into main Nov 25, 2026
70 checks passed
@swissspidy
swissspidy deleted the fix/set-autoload-update-error branch November 25, 2026 12:39
@github-actions github-actions Bot added this to the 3.0.6 milestone Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:option-set-autoload Related to 'option set-autoload' command command:option-update Related to 'option update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants