WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 4 years ago

#16990 closed enhancement (invalid)

WP Multisite doesn't use custom db-error.php

Reported by: tmuka Owned by: tmuka
Milestone: Priority: normal
Severity: minor Version: 3.0
Component: Database Keywords: has-patch
Focuses: multisite Cc:

Description

I suppose this is a feature request. I don't see a way to configure a Multisite install to use the same wp-content/db-error.php file as a single wp site install uses. Instead where the db is down the page dies on "Error establishing database connection" wrapped in an <h1>.

It could be a complication of using the HyperDB plugin, but it appears that on line 104 of wp-includes/ms-settings.php when the db is down get_blog_details() obviously fails and wp-includes/ms-load.php:ms_not_installed() is called. Unfortunately ms_not_installed() does not redirect to db-error.php, and instead dies, returning $title = /*WP_I18N_FATAL_ERROR*/'Error establishing database connection'/*/WP_I18N_FATAL_ERROR*/;

Obviously i could hack in a call to wp-includes/functions.php: dead_db() in ms-load.php, but i try to avoid any core hacking to make upgrades easier.

Does anyone have a suggestion for overriding this behavior cleanly? perhaps something in wp-WP_CONTENT_DIR/sunrise.php ?

I suppose if somebody else is interested in the simple fix, here it is. In "function ms_not_installed" on line 224 of wp-includes/ms-load.php, insert dead_db(); like this...

function ms_not_installed() {
dead_db(); //hacked this in so we can get use our custom db-error.php

The bottom line is that now the visitor will potentially see a more friendly error message when the db or db table is unavailable.

Attachments (1)

16990.patch (773 bytes) - added by noam@… 5 years ago.
Include check for custom DB error template wp-content/db-error.php in db_connect(). This should allow db-error.php to work on Multisite.

Download all attachments as: .zip

Change History (9)

#1 @tmuka
8 years ago

It appears that without the HyperDB plugin similar output occurs but from wp-includes/wp-db.php line 1042. Perhaps in wp 3.0 db-error.php and dead_db() have been abandoned?

#2 @SergeyBiryukov
8 years ago

  • Keywords needs-patch added

#3 follow-up: @c3mdigital
5 years ago

  • Keywords needs-patch removed
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from 3.1 to 3.0

in 3.4 we added load_translations_early() which will prevent the WP_I18N_FATAL_ERROR

#4 in reply to: ↑ 3 @SergeyBiryukov
5 years ago

  • Keywords needs-patch added
  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to c3mdigital:

in 3.4 we added load_translations_early() which will prevent the WP_I18N_FATAL_ERROR

WP_I18N_* comments were just a way to allow makepot.php extract and translate non-gettexted messages before wp_load_translations_early() was introduced in #18180. The request in this ticket has nothing to do with that.

@noam@…
5 years ago

Include check for custom DB error template wp-content/db-error.php in db_connect(). This should allow db-error.php to work on Multisite.

#5 @noam@…
5 years ago

  • Keywords has-patch added; needs-patch removed

#6 @jeremyfelt
5 years ago

  • Component changed from Multisite to Database
  • Focuses multisite added

This ticket was mentioned in Slack in #core-multisite by earnjam. View the logs.


4 years ago

#8 @jeremyfelt
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

Multisite does make use of the custom db-error.php file, but ms_not_installed() does not. It's an instance where a DB error is reported on the front end even though it may not be the full story. Let's defer to #30002 for any improvements to that function.

Note: See TracTickets for help on using tickets.