Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/wp-includes/class-wpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,8 @@ public function flush() {
* If `$allow_bail` is false, the lack of database connection will need to be handled manually.
*
* @since 3.0.0
* @since 3.9.0 $allow_bail parameter added.
* @since 3.9.0 Added `$allow_bail` parameter.
* @since 7.2.0 Added status and no-cache headers before loading a custom `db-error.php` drop-in.
*
* @param bool $allow_bail Optional. Allows the function to bail. Default true.
* @return bool True with a successful connection, false on failure.
Expand Down Expand Up @@ -2009,8 +2010,13 @@ public function db_connect( $allow_bail = true ) {
if ( ! $this->dbh && $allow_bail ) {
wp_load_translations_early();

// Load custom DB error template, if present.
/*
* Load custom DB error template, if present.
* A 500 status header and no-cache headers are now sent before loading a custom db-error.php drop-in.
*/
if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
status_header( 500 );
nocache_headers();
require_once WP_CONTENT_DIR . '/db-error.php';
die();
}
Expand Down
3 changes: 3 additions & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5634,6 +5634,7 @@ function wp_ob_end_flush_all() {
* in WordPress 2.5.0.
*
* @since 2.3.2
* @since 7.2.0 Added status and no-cache headers before loading a custom `db-error.php` drop-in.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
Expand All @@ -5646,6 +5647,8 @@ function dead_db() {

// Load custom DB error template, if present.
if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
status_header( 500 );
nocache_headers();
require_once WP_CONTENT_DIR . '/db-error.php';
die();
}
Expand Down
7 changes: 6 additions & 1 deletion src/wp-includes/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ function wp_favicon_request() {
* the wp-content directory).
*
* @since 3.0.0
* @since 7.2.0 Added status and no-cache headers before loading a custom `maintenance.php` drop-in.
* @access private
*/
function wp_maintenance() {
Expand All @@ -403,12 +404,16 @@ function wp_maintenance() {
return;
}

require_once ABSPATH . WPINC . '/functions.php';

if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
status_header( 503 );
nocache_headers();
header( 'Retry-After: 600' );
require_once WP_CONTENT_DIR . '/maintenance.php';
die();
}

require_once ABSPATH . WPINC . '/functions.php';
wp_load_translations_early();

header( 'Retry-After: 600' );
Expand Down
Loading