Skip to content

Commit ff5ae8f

Browse files
committed
State: Add $allowMissing parameter to loadState().
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2947 44740490-163a-0410-bde0-09ae8108e29a
1 parent db33119 commit ff5ae8f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/SimpleSAML/Auth/State.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ public static function saveState(&$state, $stage, $rawId = FALSE) {
150150
*
151151
* @param string $id State identifier (with embedded restart information).
152152
* @param string $stage The stage the state should have been saved in.
153-
* @return array State information.
153+
* @param bool $allowMissing Whether to allow the state to be missing.
154+
* @return array|NULL State information, or NULL if the state is missing and $allowMissing is TRUE.
154155
*/
155-
public static function loadState($id, $stage) {
156+
public static function loadState($id, $stage, $allowMissing = FALSE) {
156157
assert('is_string($id)');
157158
assert('is_string($stage)');
158-
159+
assert('is_bool($allowMissing)');
159160
SimpleSAML_Logger::debug('Loading state: ' . var_export($id, TRUE));
160161

161162
$tmp = explode(':', $id, 2);
@@ -170,7 +171,10 @@ public static function loadState($id, $stage) {
170171
$state = $session->getData('SimpleSAML_Auth_State', $id);
171172

172173
if ($state === NULL) {
173-
/* Could not find saved data. Attempt to restart. */
174+
/* Could not find saved data. */
175+
if ($allowMissing) {
176+
return NULL;
177+
}
174178

175179
if ($restartURL === NULL) {
176180
throw new SimpleSAML_Error_NoState();

0 commit comments

Comments
 (0)