Set error if there is a problem connecting to the DB. Props skeltoac and Potter_System. fixes #5495

git-svn-id: http://svn.automattic.com/wordpress/trunk@6426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-12-20 02:10:09 +00:00
parent 4f92b64b2e
commit de5340b9f3
3 changed files with 21 additions and 2 deletions

View File

@ -13,6 +13,7 @@ if (isset($_GET['step']))
$step = $_GET['step'];
else
$step = 0;
function display_header(){
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -24,13 +25,17 @@ header( 'Content-Type: text/html; charset=utf-8' );
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
<?php
}//end function display_header();
// Let's check to make sure WP isn't already installed.
if ( is_blog_installed() ) die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
if ( is_blog_installed() ) {display_header(); die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');}
switch($step) {
case 0:
case 1: // in case people are directly linking to this
display_header();
?>
<h1><?php _e('Welcome'); ?></h1>
<p><?php printf(__('Welcome to the famous five minute WordPress installation process! You may want to browse the <a href="%s">ReadMe documentation</a> at your leisure. Otherwise, just fill in the information below and you\'ll be on your way to using the most extendable and powerful personal publishing platform in the world.'), '../readme.html'); ?></p>
@ -61,6 +66,9 @@ switch($step) {
<?php
break;
case 2:
if ( !empty($wpdb->error) )
wp_die($wpdb->error->get_error_message());
display_header();
// Fill in the data we gathered
$weblog_title = stripslashes($_POST['weblog_title']);
$admin_email = stripslashes($_POST['admin_email']);

View File

@ -6,6 +6,7 @@ define('WPINC', 'wp-includes');
require_once('../wp-includes/compat.php');
require_once('../wp-includes/functions.php');
require_once('../wp-includes/classes.php');
if (!file_exists('../wp-config-sample.php'))
wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
@ -164,6 +165,9 @@ switch($step) {
// We'll fail here if the values are no good.
require_wp_db();
if ( !empty($wpdb->error) )
wp_die($wpdb->error->get_error_message());
$handle = fopen('../wp-config.php', 'w');
foreach ($configFile as $line_num => $line) {

View File

@ -115,6 +115,7 @@ class wpdb {
<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>$db</code> database.</p>
<ul>
<li>Are you sure it exists?</li>
<li>Does the user <code>".DB_USER."</code> have permission to use the <code>$db</code> database?</li>
<li>On some systems the name of your database is prefixed with your username, so it would be like username_wordpress. Could that be the problem?</li>
</ul>
<p>If you don't know how to setup 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>");
@ -462,10 +463,16 @@ class wpdb {
* @param string $message
*/
function bail($message) { // Just wraps errors in a nice header and footer
if ( !$this->show_errors )
if ( !$this->show_errors ) {
if ( class_exists('WP_Error') )
$this->error = new WP_Error('500', $message);
else
$this->error = $message;
return false;
}
wp_die($message);
}
/**
* Checks wether of not the database version is high enough to support the features WordPress uses
* @global $wp_version