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 | 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)
Change History (9)
@
14 years ago
my attempt at an elegant fix for this.. try it out, if it's acceptable I'll send a patch.
#2
@
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:
↓ 4
@
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
@
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.
#5
@
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 :-)
3.1 for now.