The behavior I'm seeing is a bit odd. I can go into my CLI php.ini and set:

error_reporting  =  E_ALL | E_NOTICE | E_STRICT

The following then works:

# php -r 'print error_reporting(); $var++; print " ... "; print $var;'
8191
Notice: Undefined variable: var in Command line code on line 1
 ... 1

If I turn off notices, then the notice goes away. So, it seems that I have control of the setting in the general case. If I try to observe notices within the context of drush, I never can. I can even insert the following code:

  drush_print('error reporting:' . error_reporting());
  error_reporting(E_ALL | E_NOTICE | E_STRICT);
  drush_print('error reporting:' . error_reporting());

In this case, the first 'error reporting' message prints a value that is appropriate to my php.ini file setting (I can still change php.ini and see this value change), and the value changes in response to my call to error_reporting. However, the notice that should be printed on the next line is not printed. If I insert a call to "crash();" (an undefined function), then I see an error message for that, so this can't be a matter of the error messages being turned off or redirected to a file.

There is a comment in the php documentation:

If you have defined a custom error handler using set_error_handler() , the level of error reporting set using the error_reporting() function or configuration directive will only affect the E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, and E_COMPILE_WARNING error levels. All other error levels are expected to be handled by the custom error handler.

Drush does not call set_error_handler, but it is called in _drupal_bootstrap_full(), so it seems I'm on to something... except commenting out that line does not change the behavior of drush.

This is with D6.

What do I have to do to get notices to show up when using drush?

CommentFileSizeAuthor
#3 php-notices.patch1.5 KBgreg.1.anderson

Comments

moshe weitzman’s picture

I too have struggled with this at times. All I can say is that notice reporting is working for me right now.

Drush does indeed call set_error_handler in drush.php. See Search for set_error_handler('drush_error_handler');.

greg.1.anderson’s picture

Title: It should be easier to turn on and view notices in drush » How do I get error reporting to include notices with drush?
Component: Code » Interoperability
Category: feature » support
Status: Needs review » Fixed

I must have made a typo when I was searching for set_error_handler the first time. Thank you for the pointer; once I found that, I saw that in _drush_print_log, drush only logs notices if you are in 'verbose' mode. When I specify -v, I see the notices.

greg.1.anderson’s picture

Title: How do I get error reporting to include notices with drush? » It should be easier to turn on and view notices in drush
Component: Interoperability » Code
Category: support » feature
Status: Active » Needs review
StatusFileSize
new1.5 KB

This patch adds a flag to allow php notices to easily be upgraded to 'warnings' in the drush log, making them more visible. Instructions are added to example.drushrc.php to make this feature discoverable.

greg.1.anderson’s picture

Title: How do I get error reporting to include notices with drush? » It should be easier to turn on and view notices in drush
Component: Interoperability » Code
Category: support » feature

I presume this won't impact anyone, so I committed #3.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.