[wp-trac] [WordPress Trac] #41424: Use a better error message than "Error establishing a database connection" when site isn't found (was: loose error message: Error establishing a database connection)
WordPress Trac
noreply at wordpress.org
Tue Oct 10 19:44:17 UTC 2017
#41424: Use a better error message than "Error establishing a database connection"
when site isn't found
-------------------------+------------------------------
Reporter: tthorp | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: multisite
-------------------------+------------------------------
Comment (by danielbachhuber):
+1 to improving the error state when a site isn't found.
The source of this issue is `ms_not_installed()`, which calls `dead_db()`:
{{{
function ms_not_installed( $domain, $path ) {
global $wpdb;
if ( ! is_admin() ) {
dead_db();
}
}}}
Calling `dead_db()` was added in r31657, which displays the generic db
connection error. Limiting the contents of the error message was applied
all the way back in r14317.
----
This is a commonly experienced issue when moving a multisite database
between environments. If `wp search-replace` was performed incorrectly, or
not at all, the end user will experience the cryptic error.
I can reproduce this issue by:
1. Creating a new WordPress multisite instance with one site.
2. Manually setting the `domain` value in the `wp_blogs` table to
`mstest.org`.
3. Manually editing the `DOMAIN_CURRENT_SITE` constant to `mstest.dev`.
When visiting `mstest.dev` in my browser, I see:
> Error establishing a database connection
On the command line, WP-CLI is a bit more helpful with:
> Error: Site 'mstest.dev/' not found. Verify DOMAIN_CURRENT_SITE matches
an existing site or use `--url=<url>` to override.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41424#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list