クラス wpdb::check_connection()
クラス wpdb::check_connection()
定義ファイル :/blog/wp-includes/wp-db.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | public function check_connection( $allow_bail = true ) { if ( $this->use_mysqli ) { if ( @mysqli_ping( $this->dbh ) ) { return true; } } else { if ( @mysql_ping( $this->dbh ) ) { return true; } } $error_reporting = false; if ( WP_DEBUG ) { $error_reporting = error_reporting(); error_reporting( $error_reporting & ~E_WARNING ); } for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) { if ( $this->reconnect_retries === $tries && WP_DEBUG ) { error_reporting( $error_reporting ); } if ( $this->db_connect( false ) ) { if ( $error_reporting ) { error_reporting( $error_reporting ); } return true; } sleep( 1 ); } if ( did_action( 'template_redirect' ) ) { return false; } if ( ! $allow_bail ) { return false; } // We weren't able to reconnect, so we better bail. $this->bail( sprintf( ( " <h1>Error reconnecting to the database</h1> <p>This means that we lost contact with the database server at <code>%s</code>. This could mean your host's database server is down.</p> <ul> <li>Are you sure that the database server is running?</li> <li>Are you sure that the database server is not under particularly heavy load?</li> </ul> <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='https://wordpress.org/support/'>WordPress Support Forums</a>.</p> " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily). dead_db(); } |