#29794 closed defect (bug) (wontfix)
Function is_blog_installed returns database connection error if "siteurl" is empty
Reported by: | danielkanchev | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | Bootstrap/Load | Keywords: | |
Focuses: | Cc: |
Description
If the "siteurl" is an empty string then WordPress shows an error message that is not correct:
"Error establishing a database connection"
The function which handles this is "is_blog_installed":
1274 // If siteurl is not set to autoload, check it specifically 1275 if ( !isset( $alloptions['siteurl'] ) ) 1276 $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); 1279 else 1280 $installed = $alloptions['siteurl']; 1281 $wpdb->suppress_errors( $suppress );
I understand that due to security issues it is logical to show a generic error message but right now the error has nothing to do with the fact that the "siteurl" is an empty string and the error just guides people in the wrong direction. Maybe a check should be added, so that in case the "siteurl" is not a valid hostname a different generic error will be displayed?
Change History (4)
#2
@
10 years ago
- Keywords close added; 2nd-opinion removed
- Version changed from trunk to 2.9
Thanks for the report, @danelkanchev.
Before [11902] in 2.9, it looks like we would actually not throw any error, but that a new installation screen would appear. The check for siteurl
has existed as the method for determining if a site has been installed since [3670], probably because that is the first (most important?) option added.
I think it makes sense that we keep the "terse" error on the front end. If a site owner visits wp-admin/
, they'll see a more descriptive message. It is strange that the database repair does not restore a siteurl
value. It looks like this is covered by #10970 via #11394. It probably makes sense to close this ticket in favor of that.
It's also worth noting that a custom db-error.php
template can be used to change this experience.
Error message indicates legitimate issue with database variables configuration; issue simply manifests in the siteurl code if that variable is blank.