From ff5ae8f16a6bc2d9114af11b19032be86b00a689 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Tue, 18 Oct 2011 11:02:59 +0000 Subject: [PATCH] State: Add $allowMissing parameter to loadState(). git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2947 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Auth/State.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 6672ebec7..635881225 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(); -- GitLab