ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 (private readonly ilErrorHandling $error_handling, private readonly 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

HandlerInterface $current_handler = null
 

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 ( private readonly ilErrorHandling  $error_handling,
private readonly array  $sensitive_data = [] 
)
Parameters
list<string>$sensitive_data

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

45  {
46  }

Member Function Documentation

◆ contentType()

ilDelegatingHandler::contentType ( )

This is an implicit interface method of the Whoops handlers.

See also
: ::handleException

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

References null.

113  : ?string
114  {
115  if ($this->current_handler === null ||
116  !method_exists($this->current_handler, 'contentType')) {
117  return null;
118  }
119 
120  return $this->current_handler->contentType();
121  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ 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 86 of file class.ilDelegatingHandler.php.

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

86  : ?int
87  {
88  if (defined("IL_INITIAL_WD")) {
89  chdir(IL_INITIAL_WD);
90  }
91 
92  /* We must cast the superglobals back to normal arrays since the error handler needs them. They were replaced by
93  SuperGlobalDropInReplacement . The keys contain NULL bytes, so accessing values directly by key is not
94  really possible */
95  $_GET = $this->hideSensitiveData((array) $_GET);
96  $_POST = $this->hideSensitiveData((array) $_POST);
97  $_COOKIE = $this->hideSensitiveData((array) $_COOKIE);
98  $_REQUEST = $this->hideSensitiveData((array) $_REQUEST);
99 
101 
102  $this->current_handler = $this->error_handling->getHandler();
103  $this->current_handler->setRun($this->getRun());
104  $this->current_handler->setException($this->getException());
105  $this->current_handler->setInspector($this->getInspector());
106  return $this->current_handler->handle();
107  }
$_GET["client_id"]
Definition: webdav.php:30
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$_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 48 of file class.ilDelegatingHandler.php.

Referenced by handle().

48  : array
49  {
50  foreach ($key_value_pairs as $key => &$value) {
51  if (is_array($value)) {
52  $value = $this->hideSensitiveData($value);
53  }
54 
55  if (is_string($value) && in_array($key, $this->sensitive_data, true)) {
56  $value = 'REMOVED FOR SECURITY';
57  }
58 
59  if ($key === 'PHPSESSID' && is_string($value)) {
60  $value = substr($value, 0, 5) . ' (SHORTENED FOR SECURITY)';
61  }
62 
63  if ($key === 'HTTP_COOKIE') {
64  $cookie_content = explode(';', $value);
65  foreach ($cookie_content as &$cookie_pair_string) {
66  $cookie_pair = explode('=', $cookie_pair_string);
67  if (trim($cookie_pair[0]) === session_name()) {
68  $cookie_pair[1] = substr($cookie_pair[1], 0, 5) . ' (SHORTENED FOR SECURITY)';
69  $cookie_pair_string = implode('=', $cookie_pair);
70  }
71  }
72  $value = implode(';', $cookie_content);
73  }
74  }
75 
76  return $key_value_pairs;
77  }
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 37 of file class.ilDelegatingHandler.php.


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