From 67ac3fec14912fcda692f174a513a6f6a7d842cc Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Mon, 6 May 2019 20:59:35 +1000 Subject: [PATCH] Rely only on moodle registered shutdown handlers to save the session --- extlib/simplesamlphp/lib/SimpleSAML/Logger.php | 1 + extlib/simplesamlphp/lib/SimpleSAML/Session.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extlib/simplesamlphp/lib/SimpleSAML/Logger.php b/extlib/simplesamlphp/lib/SimpleSAML/Logger.php index 618c6b7b5..57e7ada07 100644 --- a/extlib/simplesamlphp/lib/SimpleSAML/Logger.php +++ b/extlib/simplesamlphp/lib/SimpleSAML/Logger.php @@ -341,6 +341,7 @@ private static function defer($level, $message, $stats) // save the message for later self::$earlyLog[] = array('level' => $level, 'string' => $message, 'statsLog' => $stats); + // register a shutdown handler if needed if (!self::$shutdownRegistered) { register_shutdown_function(array('SimpleSAML\Logger', 'flush')); diff --git a/extlib/simplesamlphp/lib/SimpleSAML/Session.php b/extlib/simplesamlphp/lib/SimpleSAML/Session.php index ccc7ccc59..3b8cbbf87 100644 --- a/extlib/simplesamlphp/lib/SimpleSAML/Session.php +++ b/extlib/simplesamlphp/lib/SimpleSAML/Session.php @@ -490,6 +490,10 @@ public function markDirty() $this->dirty = true; + // Moodle auth_saml2 hack, because we register a shutdown handler in + // moodle in the constructor we don't need to register a callback here. + return; + if (!function_exists('header_register_callback')) { // PHP version < 5.4, can't register the callback return; @@ -511,7 +515,9 @@ public function markDirty() */ public function __destruct() { - $this->save(); + // Moodle auth_saml2 hack, we don't need to save here because we have + // a custom shutdown handle registered with moodle. + // $this->save(); } /**