Needs work
Project:
Drupal core
Version:
main
Component:
database system
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2007 at 20:41 UTC
Updated:
31 Aug 2022 at 21:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
IncrediblyKenzi commentedAs a side note, the patch also includes a custom implementation (commented out) in settings.php.
Comment #2
boris mann commentedSetting this to "won't fix", since that was the agreed method for providing backports / features in older versions.
Aaron, please re-roll against HEAD, not including the custom implementation in settings.php (just include that in your comment / description), and create a new issue for it. Thanks!
Comment #3
webchickWoah, this is a great little feature! Don't won't fix it until we get it in 6. :)
Benefits:
- Right now the word "Drupal" is hard-coded in these error messages. Particularly troublesome if you're trying to mask what platform you're running your site on for security reasons (yes, security by obscurity, but still... no sense in handing someone a golden key) or if you have your own distribution called SuperCheese.
- You're also spitting sensitive database information to the general public. And unlike regular error stuff that happens which you can select under error handling to not show on screen, this will show up for everyone who views your site. Silliness.
The only thing I'm not crazy about is requiring putting this in settings.php, simply because in the case of a multisite installation you'll have 40,000 of those. Is there another place it could go?
Comment #4
webchickAlso, it might be worth giving all lack-of-db-related errors this treatment... ex: unsupported database type, PHP support not enabled, can't select database, install/update messages.
Comment #5
webchickHere's another approach... note that this doesn't actually work yet. ;)
Comment #6
webchickThe idea, though, is you place a custom function somewhere (probably settings.php, but could also be hacked into bootstrap.inc for multisite installs):
Comment #7
webchickFrom chx:
Comment #8
IncrediblyKenzi commentedI'm actually a fan of that.. far better to have a predefined function name rather than relying on a modified template-method pattern to define a custom function name... Much simpler :)
I'll re-roll against HEAD now, assuming that the function should live in settings.php.
Comment #9
IncrediblyKenzi commentedHere's the latest (see attached patch), fixes applied against HEAD.
I opted for a hybrid of the two.. Your switch statements are all in there, but by default they're handled each by their respective database engine.
Comment #10
IncrediblyKenzi commentedAs for where the custom function should live, well, I'm open to suggestions.
I had assumed that the majority of sites would want to theme their error pages slightly differently (especially in the case of multisite installs), so settings.php is still the right spot, methinks.
Comment #11
IncrediblyKenzi commentedchanging status to "code needs review," since it does ;)
Comment #12
kbahey commentedI like this concept.
+1.
Here is another approach. Not sure what people think.
It is along the lines of how the caching .inc file is pluggable via a $conf variable that points to an alternate file to use (see bootstrap.inc):
This can be done but not straightforward. We need to do:
This way, we have a default handler for each db_type (or maybe no handler, but sites can override it by custom stuff. A site would use one db type, so they only need one .inc.
What do people think?
Comment #13
dmitrig01 commented-1 to killes' approach
Comment #14
kbahey commentedkilles did not comment here. You mean kbahey? They are so different you know? ;-)
Comment #15
dmitrig01 commentedLOL sorry I mean kbahey (I was talking to killes on IRC while posting this) I don't like your approach 'cause that defeats the purpose of db_set_active. (hint: look @ the docs for that)
Comment #16
catchNo longer applies, bumping to Drupal 7
Comment #17
Crell commentedIs this still necessary given the new DB API? Error handling is now via exceptions, so it's an entirely different animal.
Comment #18
IncrediblyKenzi commentedI think it still applies.. Ideally the exception handler should be customizable. Open to hearing more on that, however.
Comment #19
senpai commentedThere was a move underfoot to provide D7 with a completely themable "database error, site offline" message. Doesn't that negate this approach? Having just skimmed this patch (#9) I find that it's trying to change the default output of a db_error and allow it to be overridden. Right? Seems to me that the themable site offline movement would handle this as well.
Comment #20
jlambert commentedI don't think that's the use case necessarily.
Imagine if you had an error condition you wanted to display to user. Would you throw up the database error, "Access denied for user 'xx'@'x.x.x.x' to database 'xxx'". This isn't friendly, and reveals a LOT of information which you probably don't want to advertise.
An override patch like this (which might even be considered a default), would be to attach an error condition, could put up something like, "We're sorry, a database error occurred, therefore masking the error (nice for security), and maybe dropping some kind of ticket into my helpdesk to let me know that things are busting up something serious. :) That's very different from a site offline.
$db_inc = variable_get('db_inc', './includes/db_' .$_GLOBALS['db_type']. '.inc');
// check if file exists first, then
require_once $db_inc;
The only problem I have with this is that this evaluation is being done on every database request. This could have some implications for larger sites, where, at least from a performance standpoint (and Drupal needs it), simple would be better. The idea is great, I'm just wondering if there is a less expensive way to write it.
Comment #21
sun.core commentedGiven the last comment, this is at least critical. Perhaps. Let's ensure and prove it's not.
Comment #22
Crell commentedThis is a feature request, so I'm going to bump it to Drupal 8. If someone from the security team wants to push it back to Drupal 7, make sure Drieschick will let us work on it at this stage of the game before doing so. :-) I'll defer to Drieschick/security folks here.
Comment #23
catchDowngrading all D8 criticals to major per http://drupal.org/node/45111
Comment #24
jhedstromProbably 8.1 at least.
Comment #38
gagarine commentedIs this still relevant?
I stumble on this after being surprised that when your DB server is down you get a blank page with error instead of some nicer page.