Repository navigation
Upgrade/Install: Fail gracefully when database upgrade queries fail. - #16184
ClearanceClarence wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
|
@propsbot refresh |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Database upgrades currently report "Update Complete" and bump
db_versioneven when upgrade queries fail. This makeswp_upgrade()andwp-admin/upgrade.phpdetect failed queries and fail gracefully.Changes
wp_upgrade()now returnstrueon success (or when no upgrade is needed) and aWP_Errorlisting the failed queries otherwise. On failure thewp_upgradeaction does not fire.upgrade_all()no longer updatesdb_version/db_upgradedif a query failed, so the upgrade runs again once the cause is resolved (see General: Check the function set_time_limit() exist before calling #4027).wp-admin/upgrade.phpshows a "Database Update Failed" screen with the number of failed queries, a pointer to the server error log and a "Try Again" button. Queries are not printed, since this screen is reachable without authentication. Thestep=upgrade_dbendpoint responds with HTTP 500 on failure.wp-admin/network/upgrade.phpstops with a message when a site's upgrade request does not return 200.wpdb::print_error()records whether errors were suppressed in each$EZSQL_ERRORentry. Suppressed errors are treated as expected failures and do not fail the upgrade.hide_errors()/show_errors()blocks around expected failures in older upgrade routines anddrop_index()now usesuppress_errors().Design notes
db_versionis never bumped. Feedback welcome on whether a filter to ignore specific errors is wanted.drop_index()no longer force-enables error display after running.Testing instructions
dbDelta()will restore:ALTER TABLE wp_posts DROP INDEX post_name;SELECT, INSERT, UPDATE, DELETE.db_versioninwp_optionsby one./wp-admin/upgrade.phpand run the update. Expected: "Database Update Failed",db_versionunchanged, the deniedALTER TABLEin the error log.db_versionupdated, index restored.Screenshots
Trac ticket
https://core.trac.wordpress.org/ticket/36887
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Claude Fable 5.2
Used for: Documentation of the code
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.