function patterns_error_handler in Patterns 6.2
Same name and namespace in other branches
- 6 patterns.module \patterns_error_handler()
- 7.2 includes/error.inc \patterns_error_handler()
- 7 includes/error.inc \patterns_error_handler()
Custom error handler used only during patterns execution in order to catch and properly handle PHP errors. Based on drupal_error_handler().
1 call to patterns_error_handler()
- patterns_sync_form_values in ./
patterns.module - Make some modifications to the form values based on the form In particular, make sure form elements with #options and #multiple set the keys of the array as the key of the value as how FAPI does it, but XML of course does not.
1 string reference to 'patterns_error_handler'
File
- ./
patterns.module, line 2893 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function patterns_error_handler($errno, $message, $filename, $line, $context) {
if ($errno & (E_ALL ^ E_NOTICE ^ E_DEPRECATED)) {
$types = array(
1 => 'error',
2 => 'warning',
4 => 'parse error',
8 => 'notice',
16 => 'core error',
32 => 'core warning',
64 => 'compile error',
128 => 'compile warning',
256 => 'user error',
512 => 'user warning',
1024 => 'user notice',
2048 => 'strict warning',
4096 => 'recoverable fatal error',
);
// For database errors, we want the line number/file name of the place that
// the query was originally called, not _db_query().
if (isset($context[DB_ERROR])) {
$backtrace = array_reverse(debug_backtrace());
// List of functions where SQL queries can originate.
$query_functions = array(
'db_query',
'pager_query',
'db_query_range',
'db_query_temporary',
'update_sql',
);
// Determine where query function was called, and adjust line/file
// accordingly.
foreach ($backtrace as $index => $function) {
if (in_array($function['function'], $query_functions)) {
$line = $backtrace[$index]['line'];
$filename = $backtrace[$index]['file'];
break;
}
}
}
// 'patterns_error' is not a real error and should be skipped
if ($message != 'patterns_error') {
watchdog('php', '%message in %file on line %line.', array(
'%error' => $types[$errno],
'%message' => $message,
'%file' => $filename,
'%line' => $line,
), WATCHDOG_ERROR);
patterns_error_set_last(array(
'message' => $message,
'type' => $errno,
'file' => $filename,
'line' => $line,
));
}
}
return TRUE;
}