Skip to content

Commit d68cb4b

Browse files
committed
🛡️ Respect log_errors setting before writing exceptions to log file
Wrap `erLhcoreClassLog::write(print_r($e, true))` calls in both `lhc_web/index.php` and `erLhcoreClassModule::runModule()` with a check of the `site` > `log_errors` config setting. 🎯 Why: previously exception details were always written to the log file regardless of user configuration, causing unwanted files and potentially leaking sensitive data. Now logging only happens when explicitly enabled — consistent with the existing behavior in `defaultExceptionHandler()` and `logSlowRequest()`. 🔒
1 parent 0608846 commit d68cb4b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎lhc_web/index.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373

7474
include_once('design/defaulttheme/tpl/lhkernel/fatal_error.tpl.php');
7575

76-
erLhcoreClassLog::write(print_r($e,true));
76+
if (erConfigClassLhConfig::getInstance()->getSetting( 'site', 'log_errors', false ) === true) {
77+
erLhcoreClassLog::write(print_r($e,true));
78+
}
7779

7880
erLhcoreClassModule::logException($e);
7981
}

‎lhc_web/lib/core/lhcore/lhmodule.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ static function runModule()
183183
echo json_encode(array('error' => true, 'message' => $e->getMessage()));
184184
} else {
185185
include_once('design/defaulttheme/tpl/lhkernel/fatal_error.tpl.php');
186-
erLhcoreClassLog::write(print_r($e,true));
186+
187+
if (erConfigClassLhConfig::getInstance()->getSetting( 'site', 'log_errors', false ) === true) {
188+
erLhcoreClassLog::write(print_r($e, true));
189+
}
190+
187191
// Try to store to DB directly error
188192
self::logException($e);
189193
}

0 commit comments

Comments
 (0)