From fcb79175953aef8d01ed13de523bbca05bdba920 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Thu, 10 May 2018 13:14:38 +0200
Subject: [PATCH] SQLPermanentStorage:  Check for expiration

Fixes https://github.com/simplesamlphp/simplesamlphp/issues/20

The suggested fix in #20 is not a proper one.. It would be overkill to call `$this->store->removeExpired();` on every lookup.. There exists a cron-hook for that.
---
 modules/core/lib/Storage/SQLPermanentStorage.php | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php
index 54bb5642b..b7e6a3b78 100644
--- a/modules/core/lib/Storage/SQLPermanentStorage.php
+++ b/modules/core/lib/Storage/SQLPermanentStorage.php
@@ -193,12 +193,9 @@ class sspmod_core_Storage_SQLPermanentStorage {
 		if (!is_null($type)) $conditions[] = "type = '" . sqlite_escape_string($type) . "'";
 		if (!is_null($key1)) $conditions[] = "key1 = '" . sqlite_escape_string($key1) . "'";
 		if (!is_null($key2)) $conditions[] = "key2 = '" . sqlite_escape_string($key2) . "'";
-		
-		if (count($conditions) === 0) return '1';
-		
-		$condition = join(' AND ', $conditions);
-		
-		return $condition;
+
+        $conditions[] = "(expire = NULL OR expire >= ".time().")";
+		return join(' AND ', $conditions);
 	}
 	
 	
-- 
GitLab