ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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
 

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)

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

References $error_handling.

41  {
42  $this->error_handling = $error_handling;
43  }

Member Function Documentation

◆ contentType()

ilDelegatingHandler::contentType ( )

This is an implicit interface method of the Whoops handlers.

See also
: ::handleException

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

110  : ?string
111  {
112  if ($this->current_handler === null ||
113  !method_exists($this->current_handler, 'contentType')) {
114  return null;
115  }
116 
117  return $this->current_handler->contentType();
118  }

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

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

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

References ILIAS\LTI\ToolProvider\$key.

Referenced by handle().

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


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