ILIAS  release_8 Revision v8.23
ilDelegatingHandler Class Reference

A Whoops error handler that delegates calls on it self to another handler that is created only in the case an error is thrown. More...

+ Inheritance diagram for ilDelegatingHandler:
+ Collaboration diagram for ilDelegatingHandler:

Public Member Functions

 __construct (ilErrorHandling $error_handling, array $sensitive_data=[])
 
 handle ()
 Last missing method from HandlerInterface. More...
 
 contentType ()
 This is an implicit interface method of the Whoops handlers. More...
 

Private Member Functions

 hideSensitiveData (array $key_value_pairs)
 

Private Attributes

ilErrorHandling $error_handling
 
HandlerInterface $current_handler = null
 
array $sensitive_data = []
 

Detailed Description

A Whoops error handler that delegates calls on it self to another handler that is created only in the case an error is thrown.

This is necessary to make it possible to use another handler when the DEVMODE is activated. During the Init-Dance (see ilInitialisation), the error handling is initialized before the client ini file is read and the DEVMODE is determined. Thus we can't initialize a handler based on the DEVMODE and need this workaround. This class is not ment to be extended, as the definition of error handlers should be handled in one place in ilErrorHandling, so this class acts rather dump and asks ilErrorHandling for a handler.

Author
Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 35 of file class.ilDelegatingHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilDelegatingHandler::__construct ( ilErrorHandling  $error_handling,
array  $sensitive_data = [] 
)
Parameters
list<string>$sensitive_data

Definition at line 45 of file class.ilDelegatingHandler.php.

References $error_handling, and $sensitive_data.

48  {
49  $this->error_handling = $error_handling;
50  $this->sensitive_data = $sensitive_data;
51  }

Member Function Documentation

◆ contentType()

ilDelegatingHandler::contentType ( )

This is an implicit interface method of the Whoops handlers.

See also
: ::handleException

Definition at line 118 of file class.ilDelegatingHandler.php.

118  : ?string
119  {
120  if ($this->current_handler === null ||
121  !method_exists($this->current_handler, 'contentType')) {
122  return null;
123  }
124 
125  return $this->current_handler->contentType();
126  }

◆ handle()

ilDelegatingHandler::handle ( )

Last missing method from HandlerInterface.

Asks ilErrorHandling for the appropriate Handler and delegates it's tasks to that handler. PhpCastIsUnnecessaryInspection

Definition at line 91 of file class.ilDelegatingHandler.php.

References $_COOKIE, $_GET, $_SERVER, and hideSensitiveData().

91  : ?int
92  {
93  if (defined("IL_INITIAL_WD")) {
94  chdir(IL_INITIAL_WD);
95  }
96 
97  /* We must cast the superglobals back to normal arrays since the error handler needs them. They were replaced by
98  SuperGlobalDropInReplacement . The keys contain NULL bytes, so accessing values directly by key is not
99  really possible */
100  $_GET = $this->hideSensitiveData((array) $_GET);
101  $_POST = $this->hideSensitiveData((array) $_POST);
102  $_COOKIE = $this->hideSensitiveData((array) $_COOKIE);
103  $_REQUEST = $this->hideSensitiveData((array) $_REQUEST);
104 
106 
107  $this->current_handler = $this->error_handling->getHandler();
108  $this->current_handler->setRun($this->getRun());
109  $this->current_handler->setException($this->getException());
110  $this->current_handler->setInspector($this->getInspector());
111  return $this->current_handler->handle();
112  }
$_GET['client_id']
Definition: saml1-acs.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$_COOKIE[session_name()]
Definition: xapitoken.php:54
hideSensitiveData(array $key_value_pairs)
+ Here is the call graph for this function:

◆ hideSensitiveData()

ilDelegatingHandler::hideSensitiveData ( array  $key_value_pairs)
private

Definition at line 53 of file class.ilDelegatingHandler.php.

References ILIAS\LTI\ToolProvider\$key.

Referenced by handle().

53  : array
54  {
55  foreach ($key_value_pairs as $key => &$value) {
56  if (is_array($value)) {
57  $value = $this->hideSensitiveData($value);
58  }
59 
60  if (is_string($value) && in_array($key, $this->sensitive_data, true)) {
61  $value = 'REMOVED FOR SECURITY';
62  }
63 
64  if ($key === 'PHPSESSID' && is_string($value)) {
65  $value = substr($value, 0, 5) . ' (SHORTENED FOR SECURITY)';
66  }
67 
68  if ($key === 'HTTP_COOKIE') {
69  $cookie_content = explode(';', $value);
70  foreach ($cookie_content as &$cookie_pair_string) {
71  $cookie_pair = explode('=', $cookie_pair_string);
72  if (trim($cookie_pair[0]) === session_name()) {
73  $cookie_pair[1] = substr($cookie_pair[1], 0, 5) . ' (SHORTENED FOR SECURITY)';
74  $cookie_pair_string = implode('=', $cookie_pair);
75  }
76  }
77  $value = implode(';', $cookie_content);
78  }
79  }
80 
81  return $key_value_pairs;
82  }
string $key
Consumer key/client ID value.
Definition: System.php:193
hideSensitiveData(array $key_value_pairs)
+ Here is the caller graph for this function:

Field Documentation

◆ $current_handler

HandlerInterface ilDelegatingHandler::$current_handler = null
private

Definition at line 38 of file class.ilDelegatingHandler.php.

◆ $error_handling

ilErrorHandling ilDelegatingHandler::$error_handling
private

Definition at line 37 of file class.ilDelegatingHandler.php.

Referenced by __construct().

◆ $sensitive_data

array ilDelegatingHandler::$sensitive_data = []
private

Definition at line 40 of file class.ilDelegatingHandler.php.

Referenced by __construct().


The documentation for this class was generated from the following file: