Move error/exception handler higher up in the bootstrap process

killes@www.drop.org - October 23, 2008 - 14:43
Project:Drupal
Version:7.x-dev
Component:base system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Description

It is currently only set during the full bootstrap which is a bit late if e.g. some errors occur earlier.

#1

Damien Tournoud - October 23, 2008 - 16:49
Assigned to:Anonymous» Damien Tournoud

Agreed, that may require some bootstrap tweaking. Assigning myself.

#2

Crell - November 10, 2008 - 21:39

This should be set as early as humanly possible. Like, immediately after including bootstrap.inc. There's no too-early for this to be set. :-) (Well, except "before the function has been defined".)

#3

picco - April 27, 2009 - 21:40

What's the correct way to do it, i tried the following?
* move set_error_hander and set_exception_handler to the beginning of _drupal_bootstrap
* move dependant functions from common.inc to bootstrap.inc
* change drupal_log_error to print plain text error message before DRUPAL_BOOTSTRAP_FULL

AttachmentSizeStatusTest resultOperations
error_handler.patch16.32 KBIdleFailed: Failed to apply patch.View details | Re-test

#4

Berdir - June 10, 2009 - 11:35
Status:active» needs review

Haven't looked at the patch, just setting the status, so that bot can say that this doesn't apply anymore ;)

#5

System Message - June 11, 2009 - 05:35
Status:needs review» needs work

The last submitted patch failed testing.

#6

Damien Tournoud - August 27, 2009 - 19:48
Assigned to:Damien Tournoud» Anonymous

You don't need me as a bottleneck on this one.

#7

Arancaytar - August 27, 2009 - 19:51
Priority:normal» critical

Uncaught exceptions can contain sensitive data (site or database login info), so this is critical for security. (See #332413: [PDO] [Security] Database server failure makes Drupal emit Database user, password)

#8

NancyDru - August 28, 2009 - 16:39

subscribing because my 7.x system is totally down - makes it hard to convert my modules.

#9

Arancaytar - August 28, 2009 - 18:23
Status:needs work» needs review

From looking at the patch, this seems straightforward as anything:

1. Move alll error-handling code from common.inc to bootstrap.inc
2. Move the initialization from FULL to CONFIGURATION bootstrap stage.

I've rerolled these two changes. Also added a PHPdoc group for these functions ("Error handling"), since this should make the API page a bit more organized.

Now waiting for Testbot to explode on it.

AttachmentSizeStatusTest resultOperations
bootstrap-early-error-handling-325169-9.patch19.19 KBIdleFailed: Invalid PHP syntax in includes/bootstrap.inc.View details | Re-test

#10

System Message - August 28, 2009 - 18:35
Status:needs review» needs work

The last submitted patch failed testing.

#11

Arancaytar - August 29, 2009 - 13:34
Status:needs work» needs review

I had some rubbish in my text editor, apparently.

AttachmentSizeStatusTest resultOperations
bootstrap-early-error-handling-325169-11.patch9.56 KBIdleFailed: Failed to run tests.View details | Re-test

#12

System Message - August 29, 2009 - 13:50
Status:needs review» needs work

The last submitted patch failed testing.

#13

Arancaytar - August 29, 2009 - 18:46
Status:needs work» needs review

It worked on my computer. Try again?

#14

System Message - August 29, 2009 - 19:00
Status:needs review» needs work

The last submitted patch failed testing.

#15

Arancaytar - August 29, 2009 - 20:02
Status:needs work» needs review

In other news, I'm a dunce. :P

Here's the diff including bootstrap.inc.

AttachmentSizeStatusTest resultOperations
bootstrap-early-error-handling-325169-14.patch19.18 KBIdleFailed: Failed to apply patch.View details | Re-test

#16

System Message - September 18, 2009 - 09:00
Status:needs review» needs work

The last submitted patch failed testing.

#17

Damien Tournoud - October 13, 2009 - 16:05
Title:Move set_error_handler higher up in the bootstrap process» Move error/exception handler higher up in the bootstrap process

#18

moshe weitzman - October 15, 2009 - 14:28

Anyone working on this? It is a real problem for drush, among many other things.

#19

alexw - October 15, 2009 - 16:56
Status:needs work» needs review

re-roll of patch from #15...

AttachmentSizeStatusTest resultOperations
error_handling.patch19.06 KBIdleFailed: 13844 passes, 6 fails, 0 exceptionsView details | Re-test

#20

System Message - October 15, 2009 - 17:16
Status:needs review» needs work

The last submitted patch failed testing.

#21

moshe weitzman - October 16, 2009 - 02:39

A few test failures. Anyone up for reroll?

#22

Crell - October 16, 2009 - 05:53
Status:needs work» needs review

#19 was calling a function that does not actually exist. Attached patch calls a function that does exist. No other changes.

AttachmentSizeStatusTest resultOperations
error_handling.patch19.18 KBIdleFailed: Failed to apply patch.View details | Re-test

#23

Crell - October 16, 2009 - 06:12

Per prodding from Moshe, make _drupal_log_error() safe to use before t() is available.

AttachmentSizeStatusTest resultOperations
error_handling.patch19.31 KBIdleFailed: Failed to apply patch.View details | Re-test

#24

Crell - October 16, 2009 - 06:34

Remove more t(). (A nod to the coffee drinkers...)

AttachmentSizeStatusTest resultOperations
error_handling.patch19.33 KBIdleFailed: Failed to apply patch.View details | Re-test

#25

adrian - October 20, 2009 - 14:22

my issue with the error / exception handler is that it falls prey to drupal4hu.com/node/222

<?php
in  (line  of ). [29.59 sec]                                      [error]
in  (line  of ). [29.591 sec]                                     [error]
An error occurred at function :                                      [error]
?>

and

<?php
Fatal error
: Exception thrown without a stack frame in Unknown on line 0

Call Stack
:
  
30.0299   1. _drupal_exception_handler() /Users/adrian/Projects/hosting/platforms/HEAD/includes/bootstrap.inc:0
   30.0301   2. _drupal_log_error
() /Users/adrian/Projects/hosting/platforms/HEAD/includes/bootstrap.inc:2110
?>

what it comes down to is that drupal_log_error should not be called from the error handler, and if it is it should not be throwing exceptions itself, which is what watchdog() is doing.

I want to suggest we put the following into drupal_log_error, because maintenance mode is basically the textbook definition of 'we can't rely on the database to be there to do the logging'

<?php
if (defined('maintenance_mode')) {
return;
}
?>

#26

adrian - October 20, 2009 - 14:23

sorry, correction :

what it comes down to is that drupal_log_error should not be called from the exception handler, and if it is it should not be throwing exceptions itself, which is what watchdog() is doing.

#27

System Message - November 7, 2009 - 00:00
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.