Ticket #4207 (closed enhancement: duplicate)

Opened 1 year ago

Last modified 8 months ago

Pluggable DB Down Page

Reported by: linickx Assigned to: darkfate
Priority: low Milestone:
Component: General Version:
Severity: normal Keywords: needs-patch
Cc:

Description (Last modified by rob1n)

I believe most pro-bloggers would appreciate this.

Can we have a simple way to "plug" the database down page, i.e once we've got wordpress setup the default wordpress error message doesn't look as professional as one which was integrated into a users theme.

Something simple inside "~/wp-includes/wp-db.php; function bail()" should be enough, I was thinking of ....

function bail($message) { // Just wraps errors in a nice header and footer
        if ( !$this->show_errors )
                return false;
		if (file_exists('wp-content/db-down.php')) {
			 include('wp-content/db-down.php');
		} else {	 
        header( 'Content-Type: text/html; charset=utf-8');
        echo <<<HEAD
        <!DOCTYPE htm.... blah blah
		}
		die();
}
}

Thanks :)

Attachments

wp-db.php.patch (0.5 kB) - added by darkfate on 10/07/07 15:33:35.
patch to look for db-down.php in wp-includes, go to default if not found
wp-db.php.2.patch (0.6 kB) - added by darkfate on 10/07/07 21:42:03.
updated to go to wp-content

Change History

04/29/07 18:50:10 changed by rob1n

  • description changed.

04/29/07 18:50:42 changed by rob1n

  • description changed.

04/30/07 18:04:06 changed by Otto42

Good idea. The problem is that the wp-db.php file loads way before pluggable or plugins or even the theme files. It's one of the very first files to load.

Hacking your code code is an obvious way to do it, of course. Unpleasant, but there you go.

Another not-so-obvious way is to copy the wp-db.php file to wp-content/db.php and hack it there instead. When Wordpress sees a db.php file in wp-content, it uses it instead of wp-db.php. The idea there seems to be to allow people to replace the DB code with other code entirely, perhaps to support other databases than mySQL.

But that's just ways to do it right now, of course.

05/01/07 14:55:21 changed by linickx

Thanks, Basically I wanted a way to "theme" the DB down page after I've got WP running.

I had an issue with an "iffy" mysql db and my site was replaced with the normal "have you set up your db correctly ?", whereas what I needed was a "sorry but my site is down" page.

Thanks for the tip about using a db.php in wp-content, that'll save me having to hack wp after every upgrade :-D

05/01/07 15:45:56 changed by Otto42

Yeah, I thought of a themed page, but the problem is that without the database, the code has no way to know what your theme is. So it would have to live outside the normal theme directories and such, and this adds some confusion to the whole theme idea.

05/01/07 15:58:59 changed by technosailor

How about, when a theme is activated, we write some code to look for dbdown.php in the theme directory. If it exists, then a constant is written into wp-config.php with the url to the dbdown.php. By default, we serve up the standard db down page, however, if the constant is defined we serve that page up instead? Just thinking out loud...

05/01/07 18:36:20 changed by linickx

sorry, perhaps I shouldn't have used the word "theme", you're right, it does add confusion. ;-) and perhaps over complexity .(if that makes sense?)

Personally, all I would like to see is an accepted solution to "if wordpress is down, do this" where by "this" is some externally executed code, ie. display a page, spam the admin, exec("mysqld restart"), whatever the admin can dream up :-D

05/01/07 18:59:11 changed by intoxination

I believe the best solution would be to define a constant in wp-config to point to a user created database down page. If that constant isn't defined then the standard WP page shows. There is no way for WP to know which theme to look in since it can't connect to the database to see which theme is activated. The only option I see is going the constant route, then adding a page to codex explaining it.

Anyway - I give this idea a big +1

05/01/07 22:48:16 changed by masquerade

I think the original solution that was originally suggested in the actual ticket, that seems to have been ignored, is the best idea. Its kinda frustrating that it was just entirely ignored by the responses to the ticket.

No (attempts at) writing to strange files automatically. No magic constants. Do like we do with many other files. Fin.

10/07/07 15:33:35 changed by darkfate

  • attachment wp-db.php.patch added.

patch to look for db-down.php in wp-includes, go to default if not found

(follow-up: ↓ 13 ) 10/07/07 15:34:41 changed by darkfate

You can use $message in db-down.php too, but I'm assuming the whole point is to add your own text.

10/07/07 15:34:48 changed by darkfate

  • owner changed from anonymous to darkfate.
  • status changed from new to assigned.

10/07/07 15:36:51 changed by darkfate

  • keywords set to has-patch.

(in reply to: ↑ 10 ; follow-up: ↓ 14 ) 10/07/07 20:19:28 changed by westi

  • keywords changed from has-patch to needs-patch.

The current patch doesn't quite cut it.

The configurable file should need to be placed in wp-content not wp-includes like all the other files.

Should we not make wp_die itself pluggable instead to make all die messages themeable?

10/07/07 21:42:03 changed by darkfate

  • attachment wp-db.php.2.patch added.

updated to go to wp-content

(in reply to: ↑ 13 ) 10/07/07 21:45:57 changed by darkfate

Replying to westi:

The current patch doesn't quite cut it. The configurable file should need to be placed in wp-content not wp-includes like all the other files. Should we not make wp_die itself pluggable instead to make all die messages themeable?

Well I think it's a good idea to have a default function. No need to make more excess code that only pro-bloggers are going to use. wp_die() can be used if people want the default theming and they just have to plop this file in if they want to modify it.

11/04/07 16:02:33 changed by darkfate

  • keywords changed from needs-patch to has-patch.

I'm marking this has-patch. If anyone agrees with westi, I encourage them to make another patch.

12/22/07 03:06:52 changed by darkdragon

  • keywords changed from has-patch to needs-patch.
  • status changed from assigned to closed.
  • resolution set to duplicate.
  • milestone deleted.

Closing as duplicate of #5500.

If wp_die is going to be themeable then it should be in a new ticket.