From df6ccfc7d4f3a321b402ea2bfad56b2c40ff12d3 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 7 Aug 2023 15:14:47 +0900 Subject: [PATCH] Show friendly error message for very common error conditions, such as Object class --- common/framework/Debug.php | 10 ++++++++-- common/lang/en.php | 1 + common/lang/ko.php | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/framework/Debug.php b/common/framework/Debug.php index aba9795c4..5469bbc5c 100644 --- a/common/framework/Debug.php +++ b/common/framework/Debug.php @@ -628,24 +628,30 @@ class Debug } // Add the exception to the error log. - if ($caller_errfile && $caller_errfile !== $errfile) { $log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d (via %s on line %d)', get_class($e), $e->getCode(), $e->getMessage(), $caller_errfile, $caller_errline, $errfile, $e->getLine())); + $friendly_entry = $log_entry; } else { $log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d', get_class($e), $e->getCode(), $e->getMessage(), $errfile, $e->getLine())); + $friendly_entry = $log_entry; + if ($e->getMessage() === 'Class "Object" not found') + { + $friendly_entry .= "\n\n" . lang('msg_baseobject_fix'); + } } + if (!isset(self::$_config['write_error_log']) || self::$_config['write_error_log'] !== 'none') { error_log('PHP Exception: ' . $log_entry . \PHP_EOL . self::formatBacktrace($e->getTrace())); } // Display the error screen. - self::displayErrorScreen($log_entry); + self::displayErrorScreen($friendly_entry); exit; } diff --git a/common/lang/en.php b/common/lang/en.php index c735d68fa..429ac4e73 100644 --- a/common/lang/en.php +++ b/common/lang/en.php @@ -342,6 +342,7 @@ $lang->filter['invalid_number'] = 'The format of %s is invalid. Please enter num $lang->filter['invalid_float'] = 'The format of %s is invalid. Please enter numbers only.'; $lang->filter['invalid_extension'] = 'The format of %s is invalid. e.g. gif, jpg, png'; $lang->security_warning_embed = 'Due to security concern, administrators are not allowed to view embedded items.
To view them, please use another non-administrator ID.'; +$lang->msg_baseobject_fix = 'Object → BaseObject conversion is required in a third-party program. Please fix it by consulting the file name and line number shown above.'; $lang->msg_pc_to_mobile = 'View mobile optimized version of this page'; $lang->cmd_yes = 'Yes'; $lang->cmd_no = 'No'; diff --git a/common/lang/ko.php b/common/lang/ko.php index 0f27231c7..ed36878c1 100644 --- a/common/lang/ko.php +++ b/common/lang/ko.php @@ -346,6 +346,7 @@ $lang->filter['invalid_float'] = '%s의 형식이 잘못되었습니다. 숫자 $lang->filter['invalid_extension'] = '%s의 형식이 잘못되었습니다. gif, jpg, png 등 쉼표로 구분하여 입력해야 합니다.'; $lang->security_invalid_session = '바르지 않은 접근입니다. 인증을 위해 다시 로그인해야 합니다.'; $lang->security_warning_embed = '보안 문제로 관리자 아이디로는 embed를 볼 수 없습니다. 확인하려면 다른 아이디로 접속하세요'; +$lang->msg_baseobject_fix = 'Object → BaseObject 변환이 필요한 서드파티 자료가 있습니다. 위의 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.'; $lang->msg_pc_to_mobile = '모바일에 최적화된 화면으로 보기'; $lang->cmd_yes = '예'; $lang->cmd_no = '아니오'; @@ -380,4 +381,4 @@ $lang->image_quality = '화질'; $lang->standard = '표준'; $lang->unlimited = '제한 없음'; $lang->admin = '관리자'; -$lang->stop = '중지'; +$lang->stop = '중지'; \ No newline at end of file