Skip to content
Snippets Groups Projects
Commit ed76d125 authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Take advantage of ParseError in PHP 7.

When we try to load a configuration file and there's a syntax error, PHP 7 will throw the new ParseError. We can take advantage of that to capture it and give the user a meaningful message back.

This resolves #483.
parent 3d80866b
No related branches found
No related tags found
No related merge requests found
...@@ -120,7 +120,17 @@ class SimpleSAML_Configuration ...@@ -120,7 +120,17 @@ class SimpleSAML_Configuration
// the file initializes a variable named '$config' // the file initializes a variable named '$config'
ob_start(); ob_start();
require($filename); if (interface_exists('Throwable')) {
try {
require($filename);
} catch (ParseError $e) {
self::$loadedConfigs[$filename] = self::loadFromArray(array(), '[ARRAY]', 'simplesaml');
throw new SimpleSAML\Error\ConfigurationError($e->getMessage(), $filename, array());
}
} else {
require($filename);
}
$spurious_output = ob_get_length() > 0; $spurious_output = ob_get_length() > 0;
ob_end_clean(); ob_end_clean();
......
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