Skip to content
Snippets Groups Projects
Commit 067398e8 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Add an optional parameter to SimpleSAML_Session::useTransientSession().

This way we can pass an exception that made us use transient sessions, and get the method to throw that exception after getting the transient session.
parent 8756835b
No related branches found
No related tags found
No related merge requests found
...@@ -324,8 +324,11 @@ class SimpleSAML_Session ...@@ -324,8 +324,11 @@ class SimpleSAML_Session
* *
* Create a session that should not be saved at the end of the request. * Create a session that should not be saved at the end of the request.
* Subsequent calls to getInstance() will return this transient session. * Subsequent calls to getInstance() will return this transient session.
*
* @param Exception|null $exception An exception that made us use a transient session. Specify if you want to log a
* message and that exception being thrown after loading the transient session.
*/ */
public static function useTransientSession() public static function useTransientSession($exception = null)
{ {
if (isset(self::$instance)) { if (isset(self::$instance)) {
// we already have a session, don't bother with a transient session // we already have a session, don't bother with a transient session
...@@ -333,6 +336,16 @@ class SimpleSAML_Session ...@@ -333,6 +336,16 @@ class SimpleSAML_Session
} }
self::load(new SimpleSAML_Session(true)); self::load(new SimpleSAML_Session(true));
if ($exception instanceof Exception) {
if ($exception instanceof SimpleSAML_Error_Exception) {
$cause = $exception->getCause();
if ($cause instanceof Exception) {
throw $cause;
}
}
throw $exception;
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment