diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 5e6b349e574c..c9a26f8a79f6 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -468,8 +468,8 @@ function_exists($config->fatalErrorHandler) * * @param string $name name of debug section * @param mixed $variable reference to variables that we need a trace of - * @param bool $log should we log or return the output - * @param bool $html whether to generate a HTML-escaped output + * @param bool $log should we call error_log and echo a reference, or return the output + * @param bool $html whether to generate a HTML-escaped output (not relevant if $log is truthy) * @param bool $checkPermission should we check permissions before displaying output * useful when we die during initialization and permissioning * subsystem is not initialized - CRM-13765 @@ -485,6 +485,11 @@ public static function debug($name, $variable = NULL, $log = TRUE, $html = TRUE, $name = NULL; } + if ($log) { + // We don't want html crud in our text file logs. + $html = FALSE; + } + $out = print_r($variable, TRUE); $prefix = NULL; if ($html) { @@ -504,7 +509,9 @@ public static function debug($name, $variable = NULL, $log = TRUE, $html = TRUE, $log && (!$checkPermission || CRM_Core_Permission::check('view debug output')) ) { - echo $out; + $unique = substr(md5(random_bytes(32)), 0, 12); + error_log("errorID:$unique\n$out"); + echo "Critical error. Please see server logs for errorID:$unique"; } return $out;