From 3c161db528b1a194eb952e34c1978d282b786433 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 3 Dec 2013 13:22:13 +0000
Subject: [PATCH] consentSimpleAdmin: Use new selftest-function on database
 backend.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3309 44740490-163a-0410-bde0-09ae8108e29a
---
 .../hooks/hook_sanitycheck.php                   | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php b/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php
index 117d60229..1cd997b38 100644
--- a/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php
+++ b/modules/consentSimpleAdmin/hooks/hook_sanitycheck.php
@@ -13,12 +13,18 @@ function consentSimpleAdmin_hook_sanitycheck(&$hookinfo) {
 	
 		// Parse consent config
 		$consent_storage = sspmod_consent_Store::parseStoreConfig($consentconfig->getValue('store'));
-		
-		// Get all consents for user
-		$stats = $consent_storage->getStatistics();
 
-		$hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage connection OK.';	
-		
+		if (!is_callable(array($consent_storage, 'selftest'))) {
+			/* Doesn't support a selftest. */
+			return;
+		}
+		$testres = $consent_storage->selftest();
+		if ($testres) {
+			$hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage selftest OK.';
+		} else {
+			$hookinfo['errors'][] = '[consentSimpleAdmin] Consent Storage selftest failed.';
+		}
+
 	} catch (Exception $e) {
 		$hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage();	
 	}
-- 
GitLab