Make WordPress Core

Changeset 27279


Ignore:
Timestamp:
02/26/2014 04:53:21 AM (10 years ago)
Author:
nacin
Message:

When failing to reconnect to a server that has gone away, simply fail the query once we've passed template_redirect, rather than wp_die().

props pento.
see #5932.

File:
1 edited

Legend:

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

    r27278 r27279  
    970970        if ( ! $success ) {
    971971            $this->ready = false;
    972             wp_load_translations_early();
    973             $this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
     972            if ( ! did_action( 'template_redirect' ) ) {
     973                wp_load_translations_early();
     974                $this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
    974975<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p>
    975976<ul>
     
    979980</ul>
    980981<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>' ), htmlspecialchars( $db, ENT_QUOTES ), htmlspecialchars( $this->dbuser, ENT_QUOTES ) ), 'db_select_fail' );
     982            }
    981983            return;
    982984        }
     
    13791381     * Check that the connection to the database is still up. If not, try to reconnect.
    13801382     *
    1381      * If this function is unable to reconnect, it will forcibly die.
     1383     * If this function is unable to reconnect, it will forcibly die, or if after the
     1384     * the template_redirect hook has been fired, return false instead.
    13821385     *
    13831386     * @since 3.9.0
     
    14201423
    14211424            sleep( 1 );
     1425        }
     1426
     1427        // If template_redirect has already happened, it's too late for wp_die()/dead_db().
     1428        // Let's just return and hope for the best.
     1429        if ( did_action( 'template_redirect' ) ) {
     1430            return false;
    14221431        }
    14231432
     
    14871496            if ( $this->check_connection() ) {
    14881497                $this->_do_query( $query );
     1498            } else {
     1499                $this->insert_id = 0;
     1500                return false;
    14891501            }
    14901502        }
Note: See TracChangeset for help on using the changeset viewer.