Make WordPress Core


Ignore:
Timestamp:
10/11/2026 11:48:15 PM (2 days ago)
Author:
peterwilsoncc
Message:

General: Send correct HTTP statuses for db-error/maintenance drop-ins.

Updates the HTTP headers for sites running the db-error.php or maintenance.php drop-ins. Previously sites running these drop-ins would send a 200 OK HTTP response by default if they were not specified by the drop-in. These have been updated to:

  • 500 Internal Server Error for the Database Error drop-in, matching the header sent by the default call to `wp_die().
  • 503 Service Unavailable for the maintenance mode drop-in with a retry header of 10 minutes, matching the headers sent by the default call to wp_die().

Developers can continue to customize these headers by sending the headers in the drop-ins.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/13471.

Props bradleyt, dineshinau, sabernhardt, westonruter.
Fixes #66080.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r64282 r64305  
    56645664 *
    56655665 * @since 2.3.2
     5666 * @since 7.2.0 Added status and no-cache headers before loading a custom `db-error.php` drop-in.
    56665667 *
    56675668 * @global wpdb $wpdb WordPress database abstraction object.
    … …  
    56765677        // Load custom DB error template, if present.
    56775678        if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
     5679                status_header( 500 );
     5680                nocache_headers();
    56785681                require_once WP_CONTENT_DIR . '/db-error.php';
    56795682                die();
Note: See TracChangeset for help on using the changeset viewer.