Ticket #51988: 51988.diff
File 51988.diff, 4.9 KB (added by , 22 months ago) |
---|
-
src/wp-includes/class-wpdb.php
2044 2044 return $this->db_connect( $allow_bail ); 2045 2045 } 2046 2046 } 2047 } else {2047 } elseif ( function_exists( 'mysql_connect' ) ) { 2048 2048 if ( WP_DEBUG ) { 2049 2049 $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); 2050 2050 } else { … … 2053 2053 } 2054 2054 } 2055 2055 2056 if ( ! $this->dbh && $allow_bail ) { 2057 wp_load_translations_early(); 2056 if ( ! $this->dbh ) { 2057 if ( $allow_bail ) { 2058 wp_load_translations_early(); 2058 2059 2059 // Load custom DB error template, if present.2060 if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {2061 require_once WP_CONTENT_DIR . '/db-error.php';2062 die();2063 }2060 // Load custom DB error template, if present. 2061 if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { 2062 require_once WP_CONTENT_DIR . '/db-error.php'; 2063 die(); 2064 } 2064 2065 2065 $message = '<h1>' . __( 'Error establishing a database connection' ) . "</h1>\n";2066 $message = '<h1>' . __( 'Error establishing a database connection' ) . "</h1>\n"; 2066 2067 2067 $message .= '<p>' . sprintf( 2068 /* translators: 1: wp-config.php, 2: Database host. */ 2069 __( 'This either means that the username and password information in your %1$s file is incorrect or that contact with the database server at %2$s could not be established. This could mean your host’s database server is down.' ), 2070 '<code>wp-config.php</code>', 2071 '<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>' 2072 ) . "</p>\n"; 2068 if ( ! function_exists( 'mysqli_connect' ) && ! function_exists( 'mysql_connect' ) ) { 2069 $message .= '<p>' . __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) . "</p>\n"; 2073 2070 2074 $message .= "<ul>\n"; 2075 $message .= '<li>' . __( 'Are you sure you have the correct username and password?' ) . "</li>\n"; 2076 $message .= '<li>' . __( 'Are you sure you have typed the correct hostname?' ) . "</li>\n"; 2077 $message .= '<li>' . __( 'Are you sure the database server is running?' ) . "</li>\n"; 2078 $message .= "</ul>\n"; 2071 $message .= '<p>' . sprintf( 2072 /* translators: %s: mysqli. */ 2073 __( 'Please check that the %s PHP extension is installed and enabled.' ), 2074 '<code>mysqli</code>' 2075 ) . "</p>\n"; 2076 } else { 2077 $message .= '<p>' . sprintf( 2078 /* translators: 1: wp-config.php, 2: Database host. */ 2079 __( 'This either means that the username and password information in your %1$s file is incorrect or that contact with the database server at %2$s could not be established. This could mean your host’s database server is down.' ), 2080 '<code>wp-config.php</code>', 2081 '<code>' . htmlspecialchars( $this->dbhost, ENT_QUOTES ) . '</code>' 2082 ) . "</p>\n"; 2079 2083 2080 $message .= '<p>' . sprintf( 2081 /* translators: %s: Support forums URL. */ 2082 __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ), 2083 __( 'https://wordpress.org/support/forums/' ) 2084 ) . "</p>\n"; 2084 $message .= "<ul>\n"; 2085 $message .= '<li>' . __( 'Are you sure you have the correct username and password?' ) . "</li>\n"; 2086 $message .= '<li>' . __( 'Are you sure you have typed the correct hostname?' ) . "</li>\n"; 2087 $message .= '<li>' . __( 'Are you sure the database server is running?' ) . "</li>\n"; 2088 $message .= "</ul>\n"; 2089 } 2085 2090 2086 $this->bail( $message, 'db_connect_fail' ); 2091 $message .= '<p>' . sprintf( 2092 /* translators: %s: Support forums URL. */ 2093 __( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ), 2094 __( 'https://wordpress.org/support/forums/' ) 2095 ) . "</p>\n"; 2087 2096 2088 return false; 2089 } elseif ( $this->dbh ) { 2090 if ( ! $this->has_connected ) { 2091 $this->init_charset(); 2097 $this->bail( $message, 'db_connect_fail' ); 2092 2098 } 2093 2099 2094 $this->has_connected = true; 2100 return false; 2101 } 2095 2102 2096 $this->set_charset( $this->dbh ); 2103 if ( ! $this->has_connected ) { 2104 $this->init_charset(); 2105 } 2097 2106 2098 $this->ready = true; 2099 $this->set_sql_mode(); 2100 $this->select( $this->dbname, $this->dbh ); 2107 $this->has_connected = true; 2101 2108 2102 return true; 2103 } 2109 $this->set_charset( $this->dbh ); 2104 2110 2105 return false; 2111 $this->ready = true; 2112 $this->set_sql_mode(); 2113 $this->select( $this->dbname, $this->dbh ); 2114 2115 return true; 2106 2116 } 2107 2117 2108 2118 /** … … 3900 3910 } elseif ( mysqli_connect_errno() ) { 3901 3911 $error = mysqli_connect_error(); 3902 3912 } 3903 } else {3913 } elseif ( function_exists( 'mysql_error' ) ) { 3904 3914 if ( is_resource( $this->dbh ) ) { 3905 3915 $error = mysql_error( $this->dbh ); 3906 3916 } else {