MDL-76166 auth: Ensure user is in server access logs

This commit is contained in:
Brendan Heywood
2022-11-30 13:26:27 +11:00
parent 0ea3d45e04
commit c45c98f6f2
3 changed files with 8 additions and 1 deletions
+3
View File
@@ -940,6 +940,9 @@ class manager {
// Init session key.
sesskey();
// Make sure the user is correct in web server access logs.
set_access_log_user();
}
/**
+4
View File
@@ -148,6 +148,10 @@ class core_shutdown_manager {
public static function shutdown_handler() {
global $DB;
// Always ensure we know who the user is in access logs even if they
// were logged in a weird way midway through the request.
set_access_log_user();
// Custom stuff first.
foreach (self::$callbacks as $data) {
list($callback, $params) = $data;
+1 -1
View File
@@ -1876,7 +1876,7 @@ function set_access_log_user() {
apache_note('MOODLEUSER', $logname);
}
if ($logmethod == 'header') {
if ($logmethod == 'header' && !headers_sent()) {
header("X-MOODLEUSER: $logname");
}
}