Make multisite show detailed error messages from ms_not_installed()#6239
Merged
swissspidy merged 12 commits intomainfrom Feb 18, 2026
Merged
Make multisite show detailed error messages from ms_not_installed()#6239swissspidy merged 12 commits intomainfrom
swissspidy merged 12 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Define WP_ADMIN constant before loading WordPress to ensure is_admin() returns true, allowing ms_not_installed() and similar functions to provide detailed error messages instead of generic "Error establishing a database connection" messages. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Updated the fix to only define WP_ADMIN for multisite installations, preserving the existing behavior for single-site installations and not breaking the context system tests. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
- Clarified comment about when WP_ADMIN might already be defined - Added comment to test explaining what detailed error we're checking for Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve error reporting for database connection issues
Define WP_ADMIN for multisite to show detailed database errors
Feb 12, 2026
This comment was marked as resolved.
This comment was marked as resolved.
The original approach of defining WP_ADMIN caused unintended side effects by changing WordPress multisite bootstrap behavior, leading to extra database errors and triggering the ms_site_not_found hook. New approach: Enhance wp_die_handler to detect generic database error message for multisite and replace it with detailed information about missing tables. This provides the detailed error message without changing WordPress behavior. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
- Remove unnecessary prepared statement for SHOW TABLES query - Improve error message to mention both multisite-install and backup restore - Add additional context when tables exist but site not found Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Copilot
AI
changed the title
Define WP_ADMIN for multisite to show detailed database errors
Enhance multisite database error messages in wp_die_handler
Feb 15, 2026
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
- Removed get_multisite_db_error_message() logic from utils-wp.php - Added ms_network_not_found hook in Runner.php for better error messages - Set pseudo WP_Screen before loading wp-settings.php to make is_admin() return true This ensures WordPress's ms_not_installed() shows detailed error messages - Clean up pseudo screen after WordPress loads - Updated test to use --require with networks_pre_query filter to simulate missing network Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Copilot
AI
changed the title
Enhance multisite database error messages in wp_die_handler
Make multisite show detailed error messages from ms_not_installed()
Feb 17, 2026
swissspidy
approved these changes
Feb 18, 2026
swissspidy
added a commit
that referenced
this pull request
Feb 19, 2026
Avoids side effects of `is_admin()` being defined for longer. Follow-up to #6239.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WordPress multisite's
ms_not_installed()shows detailed error messages only whenis_admin()returns true. Without this, users see "Error establishing a database connection" instead of actionable details about missing tables or unresolved domains.Changes
Runner.php: Set a pseudo
WP_Screenobject within_admin()method before loadingwp-settings.phpto makeis_admin()return true during multisite bootstrapms_not_installed()displays the full detailed error messagems_network_not_foundhook for better error handling when network is not foundframework.feature: Added test scenario that simulates network not found by using
--requirewith a PHP file that hooks intonetworks_pre_queryfilter and returns an empty arrayApproach
This solution makes WordPress's own
ms_not_installed()function provide detailed error messages by temporarily setting a pseudo screen object that makesis_admin()return true. The pseudo object is cleaned up immediately after WordPress loads, avoiding any side effects on the rest of the bootstrap process.Before
After
(The actual detailed message varies based on what WordPress detects - missing tables, missing site data, etc.)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.