From 0a61790fd1ed7999f014733a19d31f1634959c44 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Thu, 10 Jan 2013 10:10:51 +0000
Subject: [PATCH] sanitycheck: Make configuration file optional.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3219 44740490-163a-0410-bde0-09ae8108e29a
---
 docs/simplesamlphp-automated_metadata.txt | 20 --------------------
 modules/sanitycheck/hooks/hook_cron.php   | 13 +++++++------
 modules/sanitycheck/www/index.php         |  1 -
 3 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/docs/simplesamlphp-automated_metadata.txt b/docs/simplesamlphp-automated_metadata.txt
index c2d01b555..554038426 100644
--- a/docs/simplesamlphp-automated_metadata.txt
+++ b/docs/simplesamlphp-automated_metadata.txt
@@ -110,26 +110,6 @@ Add to CRON with
 
 
 
-Errors
-------
-
-Problem with sanitycheck module
-
-When executing [Run cron [daily]] ==> an error shows up 
-
-Cause : module sanitycheck  ==> It is active by default (`/var/simplesamlphp/modules/sanitycheck/default-enable`) 
-
-  * When executing Cron daily It will search all active modules and it executes the hook_cron.php for each one of them in :
-		`/var/simplesamlphp/modules/<nome_modulo>/hooks/hooks_cron.php`
-
-Meanwhile it is waiting that each module conf file exists in the folder: `/var/simplesamlphp/config/config-<nome_modulo>.php`
-
-It should exist one for the sanitycheck module => `config-sanitycheck.php` but it wasn't there and therefore the error showed up.
-
-Giving an error at this modules it aborted execution for the next active modules.
-
-
-
 Configuring the metarefresh module
 ----------------------------------
 
diff --git a/modules/sanitycheck/hooks/hook_cron.php b/modules/sanitycheck/hooks/hook_cron.php
index 68ee1b20e..049447e3a 100644
--- a/modules/sanitycheck/hooks/hook_cron.php
+++ b/modules/sanitycheck/hooks/hook_cron.php
@@ -13,12 +13,13 @@ function sanitycheck_hook_cron(&$croninfo) {
 
 	try {
 	
-		$sconfig = SimpleSAML_Configuration::getConfig('config-sanitycheck.php');
-		
-		if (is_null($sconfig->getValue('cron_tag', NULL))) return;
-		if ($sconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) return;
-		
-		
+		$sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
+
+		$cronTag = $sconfig->getString('cron_tag', NULL);
+		if ($cronTag === NULL || $cronTag !== $croninfo['tag']) {
+			return;
+		}
+
 		$info = array();
 		$errors = array();
 		$hookinfo = array(
diff --git a/modules/sanitycheck/www/index.php b/modules/sanitycheck/www/index.php
index 76eb731fe..d8b608838 100644
--- a/modules/sanitycheck/www/index.php
+++ b/modules/sanitycheck/www/index.php
@@ -2,7 +2,6 @@
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$sconfig = SimpleSAML_Configuration::getConfig('config-sanitycheck.php');
 
 $info = array();
 $errors = array();
-- 
GitLab