If the database connect fails, the database layer calls
drupal_maintenance_page,
which calls drupal_get_path
which calls drupal_get_filename
which queries the database.
There are two solutions, add a $check_db arg to drupal_get_path or call drupal_get_filename directly from
theme_maintenance page. Since most normal activity requires database connectivity I've just written a patch to call drupal_get_filename directly.
I've also got an alter patch which extends drupal_get_path, but I'm not sure if minor API changes can make it in at this point.
I'm posting as critical, as the last thing we want users to experience when first install drupal is big confusing error messages for something they haven't configured yet... I'm calling it a bug since we shouldn't query the db if we unable to connect to it.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | drupal_get_filename_0.patch | 3.57 KB | robertdouglass |
| #12 | 99030.patch.txt | 2.66 KB | dopry |
| #10 | drupal_get_filename.patch | 3.23 KB | robertdouglass |
| #6 | 99030-drupal_get_path.patch_1.txt | 1.77 KB | dopry |
| #5 | 99030-drupal_get_path.patch_0.txt | 2.39 KB | dopry |
Comments
Comment #1
dopry commentedHere is the patch to drupal_maintenance_page, that does not add any calling arguments.
Comment #2
dopry commentedHere is the patch that extends drupal_get_path to include the $checkdb argument like drupal_get_filename which it calls. I prefer this patch. I leave it to reviewers to determine which is best...
Comment #3
dopry commentedto reproduce...
-- make sure your db authentication information is *incorrect*
-- navigate to 'mysite' and see the errors from mysql_* and company not being able to
query the database if you're running mysql.
You may need E_ALL as well.
Comment #4
RobRoy commentedShould be $check_db instead of $checkdb in #3.
Comment #5
dopry commentedupdate version of the drupal_get_path patch with check_db instead of checkdb.
Comment #6
dopry commentedmaybe a version without my settings.php would be better. :)
Comment #7
RobRoy commentedLooks good. Skips the DB check as advertised. Nice code comments.
Comment #8
eaton commentedA big +1 on this. It would probably serve us well to hunt for more of these unspoken db assumptions in really low level drupal functions. There's no reason we should hit the DB on a no-DB error screen. ;)
Comment #9
dries commentedThe code comments need more work. They are only accessible to Drupal experts, and not to Drupal newbies.
We should also improve that parameter in drupal_get_filename() where the code comment is copy-pasted from.
Please work a bit more on the code comments so the Average Drupal Developer can understand them.
Comment #10
robertdouglass commentedOk, I wrote a book for it. Let me know if it is too much.
Comment #11
robertdouglass commentedComment #12
dopry commentedwell I was having trouble coming up with better comments, so I just eliminated the argument and used active_db instead.
Comment #13
robertdouglass commentedThhis patch merges in the docs that I wrote and makes the $files array static again.
Comment #14
dopry commentedI hope we have a a winner.
Comment #15
dries commentedCleaned up the documentation a bit and committed it to CVS HEAD.
Comment #16
(not verified) commented