Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
devel_backtrace_suppression.patch | 972 bytes | dman | |
Comments
Comment #1
webchickI 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:
Without the patch, messy glop of debug code in drupal_set_message().
With the patch, nothing, as intended.
Still applies with offset. RTBC.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedcommitted to all branches. thx.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.