diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 6672ebec7b67d9f61143a88a5abf32bf3e323dc1..635881225f2f27b373031e06a04bf4adb743512a 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -150,12 +150,13 @@ class SimpleSAML_Auth_State { * * @param string $id State identifier (with embedded restart information). * @param string $stage The stage the state should have been saved in. - * @return array State information. + * @param bool $allowMissing Whether to allow the state to be missing. + * @return array|NULL State information, or NULL if the state is missing and $allowMissing is TRUE. */ - public static function loadState($id, $stage) { + public static function loadState($id, $stage, $allowMissing = FALSE) { assert('is_string($id)'); assert('is_string($stage)'); - + assert('is_bool($allowMissing)'); SimpleSAML_Logger::debug('Loading state: ' . var_export($id, TRUE)); $tmp = explode(':', $id, 2); @@ -170,7 +171,10 @@ class SimpleSAML_Auth_State { $state = $session->getData('SimpleSAML_Auth_State', $id); if ($state === NULL) { - /* Could not find saved data. Attempt to restart. */ + /* Could not find saved data. */ + if ($allowMissing) { + return NULL; + } if ($restartURL === NULL) { throw new SimpleSAML_Error_NoState();