From ac0b19ffe9b11e36c9793b297e63dac1a8188034 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Wed, 19 Sep 2007 07:55:46 +0000 Subject: [PATCH] lib/setup: Cleanup warnings in apacheloguser handling --- lib/setup.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 3558e98c1a..46655ce3cf 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -646,10 +646,17 @@ if (!empty($syscontextid)) { /// Apache log intergration. In apache conf file one can use ${MOODULEUSER}n in /// LogFormat to get the current logged in username in moodle. - if ($USER && function_exists('apache_note') && !empty($CFG->apacheloguser)) { - $apachelog_username = clean_filename($USER->username); - $apachelog_name = clean_filename($USER->firstname. " ".$USER->lastname); + if ($USER && function_exists('apache_note') + && !empty($CFG->apacheloguser) && isset($user->username)) { $apachelog_userid = $USER->id; + $apachelog_username = clean_filename($USER->username); + $apachelog_name = ''; + if (isset($USER->firstname)) { + // We can assume both will be set + // - even if to empty. + $apachelog_name = clean_filename($USER->firstname . " " . + $USER->lastname); + } if (isset($USER->realuser)) { if ($realuser = get_record('user', 'id', $USER->realuser)) { $apachelog_username = clean_filename($realuser->username." as ".$apachelog_username); -- 2.39.5