Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#15682 closed defect (bug) (fixed)

Entering invalid DB information causes WP installer to silently die()

Reported by: itsananderson's profile itsananderson Owned by:
Milestone: 3.1 Priority: normal
Severity: major Version: 3.1
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

If a user provides invalid database connection information (such as an invalid DB username or password) during the installation process, the WordPress installer exits without printing any sort of error message.

I dug around a bit in the source and it looks like the installer attempts connect to the database with the provided data, and if wpdb fails to connect, it wp_die()s the connection error.

http://core.trac.wordpress.org/browser/trunk/wp-admin/setup-config.php#L180

The problem is that if there's a problem connecting to the DB, it never gets back to setup-config.php, because $wpdb->show_errors is set to false, so $wpdb->db_connect() will die() without printing any error message.

http://core.trac.wordpress.org/browser/trunk/wp-includes/wp-db.php#L1047

The fix might actually be as simple as 1) setting $wpdb->show_errors to true during the install process or 2) not die()ing immediately if there's a connection problem. Another option would be to check whether WP_INSTALLING is defined before die()ing.

Attachments (3)

wp-db.php (42.9 KB) - added by zippykid 14 years ago.
my attempt at an elegant fix for this.. try it out, if it's acceptable I'll send a patch.
15682.patch (1.5 KB) - added by zippykid 14 years ago.
resubmitted with suggestions from comments.
15682.diff (1.1 KB) - added by nacin 14 years ago.

Download all attachments as: .zip

Change History (9)

#1 @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.1

3.1 for now.

@zippykid
14 years ago

my attempt at an elegant fix for this.. try it out, if it's acceptable I'll send a patch.

#2 @zippykid
14 years ago

  • Cc zippykid added

I've attached wp-db.php here, what it does is the following..

If WP_INSTALLING is true, it calls $this->bail, with a different error message string, sets $this->show_errors to true.

#3 follow-up: @zippykid
14 years ago

I think a more elegant solution may be to set show_errors(true) in the constructor of wpdb, if WP_INSTALLING === true. I kinda wrote this as I was experiencing the same issue and was debugging..

#4 in reply to: ↑ 3 @nacin
14 years ago

Replying to zippykid:

I think a more elegant solution may be to set show_errors(true) in the constructor of wpdb, if WP_INSTALLING === true.

That sounds fine.

We don't need to check for === true. In fact, we can't, because sometimes it won't be defined, and that'll trigger a notice.

We instead want to just check defined( 'WP_INSTALLING' ). Line 499, where it says if ( WP_DEBUG ) can change to if ( WP_DEBUG || defined( 'WP_INSTALLING' ) ).

Actually, we want that to be defined( 'WP_SETUP_CONFIG' ) instead. We'll call show_errors() ourselves during the install process.

I doubt this has been caught previously since we test typically with WP_DEBUG on.

@zippykid
14 years ago

resubmitted with suggestions from comments.

@nacin
14 years ago

#5 @nacin
14 years ago

Actually took a look at the code this time and figured out what was going on. See 15682.diff.

Trac tip: try not to replace a patch when re-uploading (unless you're fixing a mistake you caught when uploading it). It's good to see iterations. Thanks :-)

#6 @nacin
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [16788]) Don't improperly whitescreen on incorrect DB credentials during setup-config. Show error message with an opportunity to try again. fixes #15682.

Follow up: #15729.

Note: See TracTickets for help on using tickets.