From 41c6b83e2a1803c0d3abe7f4d475512e8ff3e942 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 3 Dec 2012 12:27:43 +0000
Subject: [PATCH] saml: Fix SAML 2.0 SP logout with PostgreSQL.

The PostgreSQL database server returns all column names in lowercase,
but we are using mixed case column names. This patch changes the query
to always request lowercase column names.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3207 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml/lib/SP/LogoutStore.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index 8ef5aa213..b9604916d 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -108,14 +108,15 @@ class sspmod_saml_SP_LogoutStore {
 			'now' => gmdate('Y-m-d H:i:s'),
 		);
 
-		$query = 'SELECT _sessionIndex, _sessionId FROM ' . $store->prefix . '_saml_LogoutStore' .
+		/* We request the columns in lowercase in order to be compatible with PostgreSQL. */
+		$query = 'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM ' . $store->prefix . '_saml_LogoutStore' .
 			' WHERE _authSource = :_authSource AND _nameId = :_nameId AND _expire >= :now';
 		$query = $store->pdo->prepare($query);
 		$query->execute($params);
 
 		$res = array();
 		while ( ($row = $query->fetch(PDO::FETCH_ASSOC)) !== FALSE) {
-			$res[$row['_sessionIndex']] = $row['_sessionId'];
+			$res[$row['_sessionindex']] = $row['_sessionid'];
 		}
 
 		return $res;
-- 
GitLab