Make WordPress Core

Ticket #5932: 5932.9.diff

File 5932.9.diff, 2.2 KB (added by pento, 11 years ago)
  • src/wp-includes/wp-db.php

     
    966966                }
    967967                if ( ! $success ) {
    968968                        $this->ready = false;
    969                         wp_load_translations_early();
    970                         $this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
     969                        if ( ! did_action( 'wp_head' ) ) {
     970                                wp_load_translations_early();
     971                                $this->bail( sprintf( __( '<h1>Can&#8217;t select database</h1>
    971972<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>
    972973<ul>
    973974<li>Are you sure it exists?</li>
     
    975976<li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
    976977</ul>
    977978<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' );
     979                        }
    978980                        return;
    979981                }
    980982        }
     
    13711373        /**
    13721374         * Check that the connection to the database is still up. If not, try to reconnect.
    13731375         *
    1374          * If this function is unable to reconnect, it will forcibly die.
     1376         * If this function is unable to reconnect, it will forcibly die before wp_head has been
     1377         * triggered, or return false after wp_head has been triggered.
    13751378         *
    13761379         * @since 3.9.0
    13771380         *
     
    14141417                        sleep( 1 );
    14151418                }
    14161419
     1420                // If wp_head has already happened, wp_die()/dead_db() won't work properly,
     1421                // so let's just return and hope for the best.
     1422                if ( did_action( 'wp_head' ) ) {
     1423                        return false;
     1424                }
     1425
    14171426                // We weren't able to reconnect, so we better bail.
    14181427                $this->bail( sprintf( ( "
    14191428<h1>Error reconnecting to the database</h1>
     
    14791488                if ( empty( $this->dbh ) || 2006 == $mysql_errno ) {
    14801489                        if ( $this->check_connection() ) {
    14811490                                $this->_do_query( $query );
     1491                        } else {
     1492                                $this->insert_id = 0;
     1493                                return false;
    14821494                        }
    14831495                }
    14841496