#13657 closed enhancement (fixed)
When WP_DEBUG is true show better errors for establishing database connection
Reported by: | sivel | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.1 | Priority: | low |
Severity: | trivial | Version: | |
Component: | Database | Keywords: | has-patch |
Focuses: | Cc: |
Description
Right now no matter if WP_DEBUG is enabled or not we always show some generic errors for Error establishing a database connection
We should display the specific error when WP_DEBUG is enabled.
Attachments (3)
Change History (18)
#2
@
14 years ago
I would tend to think we should not be exposing the output of mysql_error() on any site. Or, if we do, then we at least also check for display_errors/WP_DEBUG_DISPLAY, in case they want WP_DEBUG (as can be common in production) but are logging it.
#5
@
14 years ago
The way that translations are handled for these errors makes it difficult to do conditionals like this. Mainly due to duplicating large portions of code and strings. Well maybe not large but more than I am comfortable with duplicating.
I may just need to stare at the code for a bit to get a creative solution, that is unless someone has recommendations.
#9
@
9 years ago
- Keywords needs-refresh added; dev-feedback removed
The strings have since been split up, making it much easier to insert a conditional string when WP_DEBUG
and WP_DEBUG_DISPLAY
are defined.
#10
@
8 years ago
- Keywords dev-feedback added; needs-refresh removed
I updated the patch but I am not sure about mysql_error
because maybe wpdb have a wrapper for that but I am not an expert for this part.
#11
@
7 years ago
- Keywords needs-refresh added; dev-feedback removed
It would be best to put this in wpdb::bail()
. That method will always be the one called when WPDB needs to kill page loading. There's no need to check WP_DEBUG && WP_DEBUG_DISPLAY
here, as wpdb::$show_errors
is set to that.
I would suggest appending it to $message
at the start. Also, don't forget to check mysqli_error()
. :-)
Patch is just an idea of how we might do this. Open to other suggestions and patches.