ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPlainTextHandler Class Reference

A Whoops error handler that prints the same content as the PrettyPageHandler but as plain text. More...

+ Inheritance diagram for ilPlainTextHandler:
+ Collaboration diagram for ilPlainTextHandler:

Public Member Functions

 withExclusionList (array $exclusion_list)
 
 generateResponse ()
 

Protected Member Functions

 getSimpleExceptionOutput (Throwable $exception)
 
 getPlainTextExceptionOutput (bool $with_previous=true)
 Get a short info about the exception. More...
 
 tablesContent ()
 Get the header for the page. More...
 
 tables ()
 Get the tables that should be rendered. More...
 

Protected Attributes

const KEY_SPACE = 25
 

Private Member Functions

 stripNullBytes (string $ret)
 
 hideSensitiveData (array $super_global)
 
 shortenPHPSessionId (array $server)
 

Private Attributes

array $exclusion_list = []
 

Detailed Description

A Whoops error handler that prints the same content as the PrettyPageHandler but as plain text.

This is used for better coexistence with xdebug, see #16627.

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 28 of file class.ilPlainTextHandler.php.

Member Function Documentation

◆ generateResponse()

ilPlainTextHandler::generateResponse ( )

Definition at line 50 of file class.ilPlainTextHandler.php.

References getPlainTextExceptionOutput(), and tablesContent().

50  : string
51  {
52  return $this->getPlainTextExceptionOutput() . $this->tablesContent() . "\n";
53  }
tablesContent()
Get the header for the page.
getPlainTextExceptionOutput(bool $with_previous=true)
Get a short info about the exception.
+ Here is the call graph for this function:

◆ getPlainTextExceptionOutput()

ilPlainTextHandler::getPlainTextExceptionOutput ( bool  $with_previous = true)
protected

Get a short info about the exception.

Definition at line 69 of file class.ilPlainTextHandler.php.

References $message, and getSimpleExceptionOutput().

Referenced by ilTestingHandler\generateResponse(), and generateResponse().

69  : string
70  {
71  $message = Formatter::formatExceptionPlain($this->getInspector());
72 
73  if ($with_previous) {
74  $exception = $this->getInspector()->getException();
75  $previous = $exception->getPrevious();
76  while ($previous) {
77  $message .= "\n\nCaused by\n" . $this->getSimpleExceptionOutput($previous);
78  $previous = $previous->getPrevious();
79  }
80  }
81 
82  return $message;
83  }
getSimpleExceptionOutput(Throwable $exception)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSimpleExceptionOutput()

ilPlainTextHandler::getSimpleExceptionOutput ( Throwable  $exception)
protected

Definition at line 55 of file class.ilPlainTextHandler.php.

Referenced by getPlainTextExceptionOutput().

55  : string
56  {
57  return sprintf(
58  '%s: %s in file %s on line %d',
59  get_class($exception),
60  $exception->getMessage(),
61  $exception->getFile(),
62  $exception->getLine()
63  );
64  }
+ Here is the caller graph for this function:

◆ hideSensitiveData()

ilPlainTextHandler::hideSensitiveData ( array  $super_global)
private
Parameters
array<string,mixed>$super_global
Returns
array<string, mixed>

Definition at line 152 of file class.ilPlainTextHandler.php.

Referenced by tables().

152  : array
153  {
154  foreach ($this->exclusion_list as $parameter) {
155  if (isset($super_global[$parameter])) {
156  $super_global[$parameter] = 'REMOVED FOR SECURITY';
157  }
158 
159  if (isset($super_global['post_vars'][$parameter])) {
160  $super_global['post_vars'][$parameter] = 'REMOVED FOR SECURITY';
161  }
162  }
163 
164  return $super_global;
165  }
+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilPlainTextHandler::shortenPHPSessionId ( array  $server)
private
Parameters
array<string,mixed>$server
Returns
array<string, mixed>

Definition at line 171 of file class.ilPlainTextHandler.php.

References $server.

Referenced by tables().

171  : array
172  {
173  $cookie_content = $server['HTTP_COOKIE'];
174  $cookie_content = explode(';', $cookie_content);
175 
176  foreach ($cookie_content as $key => $content) {
177  $content_array = explode('=', $content);
178  if (trim($content_array[0]) === session_name()) {
179  $content_array[1] = substr($content_array[1], 0, 5) . ' (SHORTENED FOR SECURITY)';
180  $cookie_content[$key] = implode('=', $content_array);
181  }
182  }
183 
184  $server['HTTP_COOKIE'] = implode(';', $cookie_content);
185 
186  return $server;
187  }
$server
Definition: shib_login.php:24
+ Here is the caller graph for this function:

◆ stripNullBytes()

ilPlainTextHandler::stripNullBytes ( string  $ret)
private

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

Referenced by tablesContent().

45  : string
46  {
47  return str_replace("\0", '', $ret);
48  }
+ Here is the caller graph for this function:

◆ tables()

ilPlainTextHandler::tables ( )
protected

Get the tables that should be rendered.

Definition at line 128 of file class.ilPlainTextHandler.php.

References $_COOKIE, $_GET, $_SERVER, $post, $server, hideSensitiveData(), and shortenPHPSessionId().

Referenced by tablesContent().

128  : array
129  {
130  $post = $_POST;
131  $server = $_SERVER;
132 
133  $post = $this->hideSensitiveData($post);
136 
137  return [
138  'GET Data' => $_GET,
139  'POST Data' => $post,
140  'Files' => $_FILES,
141  'Cookies' => $_COOKIE,
142  'Session' => $_SESSION ?? [],
143  'Server/Request Data' => $server,
144  'Environment Variables' => $_ENV,
145  ];
146  }
$_GET["client_id"]
Definition: webdav.php:30
hideSensitiveData(array $super_global)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$server
Definition: shib_login.php:24
$_COOKIE[session_name()]
Definition: xapitoken.php:54
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tablesContent()

ilPlainTextHandler::tablesContent ( )
protected

Get the header for the page.

Definition at line 88 of file class.ilPlainTextHandler.php.

References stripNullBytes(), and tables().

Referenced by generateResponse().

88  : string
89  {
90  $ret = '';
91  foreach ($this->tables() as $title => $content) {
92  $ret .= "\n\n-- $title --\n\n";
93  if (count($content) > 0) {
94  foreach ($content as $key => $value) {
95  $key = str_pad((string) $key, self::KEY_SPACE);
96 
97  // indent multiline values, first print_r, split in lines,
98  // indent all but first line, then implode again.
99  $first = true;
100  $indentation = str_pad('', self::KEY_SPACE);
101  $value = implode(
102  "\n",
103  array_map(
104  static function ($line) use (&$first, $indentation): string {
105  if ($first) {
106  $first = false;
107  return $line;
108  }
109  return $indentation . $line;
110  },
111  explode("\n", print_r($value, true))
112  )
113  );
114 
115  $ret .= "$key: $value\n";
116  }
117  } else {
118  $ret .= "empty\n";
119  }
120  }
121 
122  return $this->stripNullBytes($ret);
123  }
tables()
Get the tables that should be rendered.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withExclusionList()

ilPlainTextHandler::withExclusionList ( array  $exclusion_list)
Parameters
list<string>$exclusion_list

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

References $exclusion_list.

38  : self
39  {
40  $clone = clone $this;
41  $clone->exclusion_list = $exclusion_list;
42  return $clone;
43  }

Field Documentation

◆ $exclusion_list

array ilPlainTextHandler::$exclusion_list = []
private

Definition at line 33 of file class.ilPlainTextHandler.php.

Referenced by withExclusionList().

◆ KEY_SPACE

const ilPlainTextHandler::KEY_SPACE = 25
protected

Definition at line 30 of file class.ilPlainTextHandler.php.


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