WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11570 closed enhancement (wontfix)

Change Default Database Error Page

Reported by: GuruXL Owned by: ryan
Milestone: Priority: high
Severity: normal Version: 2.9
Component: Database Keywords: dev-feedback close
Focuses: Cc:

Description

As a dynamic blogging system, WordPress consists of PHP files (the WP core) that interact with a MySQL database to generate the web pages for your website. When everything is working properly, this dynamic interaction keeps WordPress humming along like a champ, but when your database crashes, WordPress can’t operate and will deliver the following message to your visitors:

Error establishing a database connection

I think it’s safe to say that the default database error message:

  • is ugly
  • is useless to visitors
  • is useless to site admins
  • reveals sensitive information

A default message should be generated that gives information that the site is down and doesn't reveal information.

<?php // custom WordPress database error page tutorial @ digwp.com

	header('HTTP/1.1 503 Service Temporarily Unavailable');
	header('Status: 503 Service Temporarily Unavailable');
	header('Retry-After: 3600'); // 1 hour = 3600 seconds
	mail("webmaster@domain.com", "Database Error", "There is a problem with teh database!", "From: Montgomery Scott");

?>
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
	<head>
		<title>503 Service Temporarily Unavailable</title>
		<style type="text/css">
			h1, p {
				font-family: Helvetica, sans-serif;
				font-size: 24px;
				color: #333;
				}
			p {
				font-size: 14px;
				}
		</style>
	</head>
	<body>
		<h1>Captain, the ship can&rsquo;t take much more of this!</h1>
		<p>Perishable Press is currently experiencing technical issues &mdash; Please check back soon!</p>
	</body>
</html>

Change History (7)

comment:1 dd324 years ago

  • Keywords dev-feedback added; dbase database error removed
  • Milestone changed from 2.9.1 to Future Release
  • Type changed from defect (bug) to enhancement

The original intention of the blank error was to enforce to end-users that it was their database as the reason for failing to load, and not a) WordPress or b) Something else they may have absolutely no clue over

It at least points end users in the right direction.

On a production website, You'd want to redefine the Maintainence and Database error pages to something custom.

I cant find the original tickets related to the Dead DB pages to link right now...

Milestone: Setting to Future Release pending a patch and/or agreement that something needs to change for 3.0. Changing to enhancement rather than defect, as its enhancing an already present functionality, Even if thats to hide extra information.

comment:2 sirzooro4 years ago

If you want to send email in such situation, it should be done in smarter way. Proposed solution may flood admin email box, especially on busy sites.

comment:3 mrmist4 years ago

Yeah, an email might be desired in some cases, but without the database being available to authenticate and/or track such things it could easily be used as a basis for DOS or similar.

comment:4 scribu4 years ago

  • Keywords close added

Sending an email is a bad ideea. Serious sites should instead do regular pings from an external system.

Even if it did send an email, I don't see what useful information WP could send to the site admin, other than info related to the visitor.

comment:5 hakre4 years ago

Please enable database logging with the WPDB component to get alerts about database problems. You can help improve that component to enable better logging (incl. sending out emails) so that it better integrates with the php error_log function. For more information about PHP and error logging please see: php error_log function. Currently WPDB only supports logging to file and the syslog.

comment:6 johnbillion4 years ago

Suggesting close as wontfix.

A custom database error file can be set at wp-content/db-error.php to give visitors nicer error messages. Apart from some styling or wording changes, not a lot can be done to improve the default error message.

comment:7 nacin4 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I meant to comment to this ticket, but I never did. Instead, I sent an email to digwp.com as the tutorial (http://digwp.com/2009/11/custom-database-error-page/) has a rather fatal flaw, in that the custom db-error.php file does not check for ABSPATH, and therefore can be hit with an HTTP request and an email is sent. It also doesn't use wp_mail, or status_header, etc. But I digress.

I'm closing this as wontfix. It is already customizable via db-error.php and there are no valid reasons to change the default.

Note: See TracTickets for help on using tickets.