Skip to content
Snippets Groups Projects
Commit 4114af1f authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Error handling in sanity cron hook

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1031 44740490-163a-0410-bde0-09ae8108e29a
parent cf95fc79
No related branches found
No related tags found
No related merge requests found
...@@ -9,26 +9,34 @@ function sanitycheck_hook_cron(&$croninfo) { ...@@ -9,26 +9,34 @@ function sanitycheck_hook_cron(&$croninfo) {
assert('array_key_exists("summary", $croninfo)'); assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)'); assert('array_key_exists("tag", $croninfo)');
$config = SimpleSAML_Configuration::getInstance(); SimpleSAML_Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
$sconfig = $config->copyFromBase('sconfig', 'config-sanitycheck.php');
try {
if (is_null($sconfig->getValue('cron_tag', NULL))) return;
if ($sconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) return;
$info = array();
$errors = array();
$hookinfo = array(
'info' => &$info,
'errors' => &$errors,
);
SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) { $config = SimpleSAML_Configuration::getInstance();
foreach ($errors AS $err) { $sconfig = $config->copyFromBase('sconfig', 'config-sanitycheck.php');
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
if (is_null($sconfig->getValue('cron_tag', NULL))) return;
if ($sconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) return;
$info = array();
$errors = array();
$hookinfo = array(
'info' => &$info,
'errors' => &$errors,
);
SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
if (count($errors) > 0) {
foreach ($errors AS $err) {
$croninfo['summary'][] = 'Sanitycheck error: ' . $err;
}
} }
} catch (Exception $e) {
$croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment