From cddbdb20b25c6ac2f00641b8f629202f33b1aca9 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Wed, 17 Jul 2019 14:39:08 +0800 Subject: [PATCH] MDL-66169 admin: properly set debugsmtp, which is a config.php only var This may not be set, so care must be taken to conditionally reinstate the value, once the test email has been sent. --- admin/testoutgoingmailconf.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/testoutgoingmailconf.php b/admin/testoutgoingmailconf.php index ce5857f4ee493..7d0db03b07ac3 100644 --- a/admin/testoutgoingmailconf.php +++ b/admin/testoutgoingmailconf.php @@ -52,7 +52,7 @@ // Manage Moodle debugging options. $debuglevel = $CFG->debug; $debugdisplay = $CFG->debugdisplay; - $debugsmtp = $CFG->debugsmtp; + $debugsmtp = $CFG->debugsmtp ?? null; // This might not be set as it's optional. $CFG->debugdisplay = true; $CFG->debugsmtp = true; $CFG->debug = 15; @@ -66,7 +66,12 @@ // Restore Moodle debugging options. $CFG->debug = $debuglevel; $CFG->debugdisplay = $debugdisplay; - $CFG->debugsmtp = $debugsmtp; + + // Restore the debugsmtp config, if it was set originally. + unset($CFG->debugsmtp); + if (!is_null($debugsmtp)) { + $CFG->debugsmtp = $debugsmtp; + } if ($success) { $msgparams = new stdClass();