diff options
author | Jaime Pérez <jaime.perez@uninett.no> | 2016-07-02 17:22:43 +0200 |
---|---|---|
committer | Jaime Pérez <jaime.perez@uninett.no> | 2016-07-02 17:22:43 +0200 |
commit | 067398e8216d7de9d6c509ebf932febd6f67c8ca (patch) | |
tree | e2eb78960a75008ec15af32a70d3af7f673e1ee4 | |
parent | 8756835bacc7057734aba7fe349b534e63261253 (diff) | |
download | simplesamlphp-067398e8216d7de9d6c509ebf932febd6f67c8ca.zip simplesamlphp-067398e8216d7de9d6c509ebf932febd6f67c8ca.tar.gz simplesamlphp-067398e8216d7de9d6c509ebf932febd6f67c8ca.tar.bz2 |
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.
-rw-r--r-- | lib/SimpleSAML/Session.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 7f482a6..241b705 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -324,8 +324,11 @@ class SimpleSAML_Session * * Create a session that should not be saved at the end of the request. * 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)) { // we already have a session, don't bother with a transient session @@ -333,6 +336,16 @@ class SimpleSAML_Session } 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; + } } /** |