From 577d6dc20ac7e76d3a9cc925aefa181c3c9b643a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Mon, 26 Jul 2010 07:57:54 +0000
Subject: [PATCH] adding more robustness to metarefresh fetch.php manual fetch
 page

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2431 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/metarefresh/www/fetch.php | 60 ++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php
index 20b6aec86..70f0ba009 100644
--- a/modules/metarefresh/www/fetch.php
+++ b/modules/metarefresh/www/fetch.php
@@ -14,32 +14,42 @@ foreach ($sets AS $setkey => $set) {
 
 	SimpleSAML_Logger::info('[metarefresh]: Executing set [' . $setkey . ']');
 
-	$expireAfter = $set->getInteger('expireAfter', NULL);
-	if ($expireAfter !== NULL) {
-		$expire = time() + $expireAfter;
-	} else {
-		$expire = NULL;
-	}
-
-	$metaloader = new sspmod_metarefresh_MetaLoader($expire);
-
-	foreach($set->getArray('sources') AS $source) {
-		SimpleSAML_Logger::debug('[metarefresh]: In set [' . $setkey . '] loading source ['  . $source['src'] . ']');
-		$metaloader->loadSource($source);
-	}
-
-	$outputDir = $set->getString('outputDir');
-	$outputDir = $config->resolvePath($outputDir);
-
-	$outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
-	switch ($outputFormat) {
-		case 'flatfile':
-			$metaloader->writeMetadataFiles($outputDir);
-			break;
-		case 'serialize':
-			$metaloader->writeMetadataSerialize($outputDir);
-			break;
+	try {
+		
+
+		$expireAfter = $set->getInteger('expireAfter', NULL);
+		if ($expireAfter !== NULL) {
+			$expire = time() + $expireAfter;
+		} else {
+			$expire = NULL;
+		}
+
+		$metaloader = new sspmod_metarefresh_MetaLoader($expire);
+
+		foreach($set->getArray('sources') AS $source) {
+			SimpleSAML_Logger::debug('[metarefresh]: In set [' . $setkey . '] loading source ['  . $source['src'] . ']');
+			$metaloader->loadSource($source);
+		}
+
+		$outputDir = $set->getString('outputDir');
+		$outputDir = $config->resolvePath($outputDir);
+
+		$outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile');
+		switch ($outputFormat) {
+			case 'flatfile':
+				$metaloader->writeMetadataFiles($outputDir);
+				break;
+			case 'serialize':
+				$metaloader->writeMetadataSerialize($outputDir);
+				break;
+		}
+	} catch (Exception $e) {
+		if (! $e instanceof SimpleSAML_Error_Exception) {
+			$e = new SimpleSAML_Error_UnserializableException($e);
+		}
+		$e->logWarning();
 	}
+	
 
 }
 
-- 
GitLab