I'm parsing a page, and the parse_url() occasionally trips on malformed links.
Instead of just returning NULL, it also triggers a warning.
So my code is

...
  $link_parts = @parse_url($link);
  if(! is_array($link_parts) ) {
    drupal_set_message("Failed to rewrite found URL : '$link' ");
  }
...

but devel.module continues to throw a hissy-fit every time this happens, giving me pages of backtrace dump. For a warning I knew about and chose to ignore.

This is a 'feature' of PHP, and it apparently has a sane work-around. Recommended for anyone who's doing their own error-handling.

function backtrace_error_handler($errno, $message, $filename, $line) {
  // don't respond to the error if it
  // was suppressed with a '@'
  if (error_reporting() == 0) return;
  

patch (DRUPAL-5 today) attached.

CommentFileSizeAuthor
devel_backtrace_suppression.patch972 bytesdman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Priority: Minor » Normal
Status: Needs review » Reviewed & tested by the community

I just ran into this today myself debugging something for a client.

You can reproduce by going to admin/settings/devel and setting the error reporting to "backtrace" and then pasting the following into the execute PHP block:

@mysql_connect('lahsdhaksd', 'asdasdasd', 'asdsadasd');

Without the patch, messy glop of debug code in drupal_set_message().
With the patch, nothing, as intended.

Still applies with offset. RTBC.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Fixed

committed to all branches. thx.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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