Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#14654 closed enhancement (fixed)

When WP_DEBUG, mysql socket error should be displayed

Reported by: lloydbudd's profile lloydbudd Owned by: westi's profile westi
Milestone: 3.1 Priority: low
Severity: minor Version: 3.0.1
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

When WP_DEBUG, mysql socket error should be displayed

Currently the standard "Error establishing a database connection" is displayed:

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost. This could mean your host's database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

ENV: wp trunk r15511

REPRO
To reproduce change mysql.default_socket to some nonsense path in php.ini

ADDITIONAL DETAILS
Based on my WordCamp Genius Bar experiences this is a surprisingly common problem people have when setting up their local development environment. My Sept 2008 related post http://foolswisdom.com/mac-wordpress-error-establishing-a-database-connection/ still gets traffic and thank yous.

WORKAROUND
Don't suppress the error condition on mysql_connect() in wp-includes/wp-db.php

-               $this->dbh = @mysql_connect( $dbhost, $dbuser, $dbpassword, true );
+               $this->dbh = mysql_connect( $dbhost, $dbuser, $dbpassword, true );

Attachments (1)

14654.patch (621 bytes) - added by hakre 13 years ago.
Do Errors on first mysql_connect when WP_DEBUG is true

Download all attachments as: .zip

Change History (4)

@hakre
13 years ago

Do Errors on first mysql_connect when WP_DEBUG is true

#1 @hakre
13 years ago

  • Keywords has-patch added
  • Version set to 3.0.1

Related: #14672

#2 @westi
13 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Owner set to westi
  • Status changed from new to reviewing

#3 @westi
13 years ago

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

(In [15808]) Display mysql_connect errors when WP_DEBUG is enabled. Fixes #14654 props lloydbudd and hakre
Always die if we can't connect to the db no point in going any futher.

Note: See TracTickets for help on using tickets.