ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
_include.php
Go to the documentation of this file.
1<?php
2
3// initialize the autoloader
4require_once(dirname(dirname(__FILE__)).'/lib/_autoload.php');
5
6// enable assertion handler for all pages
8
9// show error page on unhandled exceptions
10function SimpleSAML_exception_handler($exception)
11{
12 SimpleSAML\Module::callHooks('exception_handler', $exception);
13
14 if ($exception instanceof SimpleSAML_Error_Error) {
15 $exception->show();
16 } elseif ($exception instanceof Exception) {
17 $e = new SimpleSAML_Error_Error('UNHANDLEDEXCEPTION', $exception);
18 $e->show();
19 } else {
20 if (class_exists('Error') && $exception instanceof Error) {
21 $code = $exception->getCode();
22 $errno = ($code > 0) ? $code : E_ERROR;
23 $errstr = $exception->getMessage();
24 $errfile = $exception->getFile();
25 $errline = $exception->getLine();
26 SimpleSAML_error_handler($errno, $errstr, $errfile, $errline);
27 }
28 }
29}
30
31set_exception_handler('SimpleSAML_exception_handler');
32
33// log full backtrace on errors and warnings
34function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0, $errcontext = null)
35{
36 if (!class_exists('SimpleSAML\Logger')) {
37 /* We are probably logging a deprecation-warning during parsing. Unfortunately, the autoloader is disabled at
38 * this point, so we should stop here.
39 *
40 * See PHP bug: https://bugs.php.net/bug.php?id=47987
41 */
42 return false;
43 }
44
45 if (SimpleSAML\Logger::isErrorMasked($errno)) {
46 // masked error
47 return false;
48 }
49
50 static $limit = 5;
51 $limit -= 1;
52 if ($limit < 0) {
53 // we have reached the limit in the number of backtraces we will log
54 return false;
55 }
56
57 // show an error with a full backtrace
58 $e = new SimpleSAML_Error_Exception('Error '.$errno.' - '.$errstr);
59 $e->logError();
60
61 // resume normal error processing
62 return false;
63}
64
65set_error_handler('SimpleSAML_error_handler');
66
67try {
69} catch (Exception $e) {
70 throw new \SimpleSAML\Error\CriticalConfigurationError(
71 $e->getMessage()
72 );
73}
74
75// set the timezone
SimpleSAML_exception_handler($exception)
Definition: _include.php:10
SimpleSAML_error_handler($errno, $errstr, $errfile=null, $errline=0, $errcontext=null)
Definition: _include.php:34
An exception for terminatinating execution or to throw for unit testing.
static callHooks($hook, &$data=null)
Call a hook in all enabled modules.
Definition: Module.php:281
static initTimezone()
Initialize the timezone.
Definition: Time.php:51
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static installHandler()
Install this assertion handler.
Definition: Assertion.php:56
$code
Definition: example_050.php:99
Attribute-related utility methods.