diff --git a/include/class_msg_dialog.inc b/include/class_msg_dialog.inc index e6b0b6c287aca8420393a3ce9d3a77976fdddcda..4ffc80ce326c4119844babf277740d70d5c08606 100644 --- a/include/class_msg_dialog.inc +++ b/include/class_msg_dialog.inc @@ -41,7 +41,7 @@ class msg_dialog private $s_Message; private $i_Type; private $i_ID; - private $a_Trace = []; + private $a_Trace; /*! * \brief Message dialog constructor @@ -50,9 +50,11 @@ class msg_dialog * * \param string $message The message of the message dialog * - * \param string $type The type of the message dialog, by default = INFO_DIALOG + * \param int $type The type of the message dialog, by default = INFO_DIALOG + * + * \param array $trace The trace from where the message was built */ - public function __construct ($title, $message, $type = INFO_DIALOG) + public function __construct (string $title, string $message, int $type = INFO_DIALOG, array $trace = []) { if (!in_array($type, [INFO_DIALOG,WARNING_DIALOG,ERROR_DIALOG,CONFIRM_DIALOG,FATAL_ERROR_DIALOG])) { trigger_error('Invalid msg_dialog type.'); @@ -63,6 +65,7 @@ class msg_dialog $this->s_Title = $title; $this->s_Message = $message; $this->i_Type = $type; + $this->a_Trace = $trace; } protected function show () @@ -93,7 +96,11 @@ class msg_dialog /* Append trace information, only if error messages are enabled */ if (isset($config) && is_object($config) && $config->get_cfg_value('displayerrors') == 'TRUE') { - $this->a_Trace = debug_backtrace(); + if (empty($this->a_Trace)) { + $this->a_Trace = debug_backtrace(); + } + } else { + $this->a_Trace = []; } if ($this->i_Type == FATAL_ERROR_DIALOG) { restore_error_handler(); @@ -117,11 +124,13 @@ class msg_dialog * * \param string $message The message of the message dialog * - * \param string $type The type of the message dialog, by default = INFO_DIALOG + * \param int $type The type of the message dialog, by default = INFO_DIALOG + * + * \param array $trace The trace from where the message was built */ - public static function display ($title, $message, $type = INFO_DIALOG) + public static function display (string $title, string $message, int $type = INFO_DIALOG, array $trace = []) { - $dialog = new msg_dialog($title, $message, $type); + $dialog = new msg_dialog($title, $message, $type, $trace); $dialog->show(); } diff --git a/include/errors/class_SimplePluginCheckError.inc b/include/errors/class_SimplePluginCheckError.inc index 35899f1b11367b778fd2814a38fc81e8df24159d..de9772773314618b41185152351d1992c5b9454a 100644 --- a/include/errors/class_SimplePluginCheckError.inc +++ b/include/errors/class_SimplePluginCheckError.inc @@ -71,7 +71,16 @@ class SimplePluginCheckError extends FusionDirectoryError $html .= '<br/><br/><i>'.sprintf(_('Example: %s'), htmlescape($example)).'</i> '; } + $trace = $this->getTrace(); - return [_('Error'), $html, ERROR_DIALOG]; + array_unshift( + $trace, + [ + 'file' => $this->getFile(), + 'line' => $this->getLine(), + ] + ); + + return [_('Error'), $html, ERROR_DIALOG, $trace]; } }