WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#14654 closed enhancement (fixed)

When WP_DEBUG, mysql socket error should be displayed

Reported by: lloydbudd Owned by: 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 4 years ago.
Do Errors on first mysql_connect when WP_DEBUG is true

Download all attachments as: .zip

Change History (4)

hakre4 years ago

Do Errors on first mysql_connect when WP_DEBUG is true

comment:1 hakre4 years ago

  • Keywords has-patch added
  • Version set to 3.0.1

Related: #14672

comment:2 westi4 years ago

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

comment:3 westi4 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.