Passed
Push — master ( 2bedfb...70a54e )
by Roeland
11:48 queued 11s
created
lib/private/legacy/OC_Template.php 1 patch
Indentation   +307 added lines, -307 removed lines patch added patch discarded remove patch
@@ -48,311 +48,311 @@
 block discarded – undo
48 48
  */
49 49
 class OC_Template extends \OC\Template\Base {
50 50
 
51
-	/** @var string */
52
-	private $renderAs; // Create a full page?
53
-
54
-	/** @var string */
55
-	private $path; // The path to the template
56
-
57
-	/** @var array */
58
-	private $headers = []; //custom headers
59
-
60
-	/** @var string */
61
-	protected $app; // app id
62
-
63
-	protected static $initTemplateEngineFirstRun = true;
64
-
65
-	/**
66
-	 * Constructor
67
-	 *
68
-	 * @param string $app app providing the template
69
-	 * @param string $name of the template file (without suffix)
70
-	 * @param string $renderAs If $renderAs is set, OC_Template will try to
71
-	 *                         produce a full page in the according layout. For
72
-	 *                         now, $renderAs can be set to "guest", "user" or
73
-	 *                         "admin".
74
-	 * @param bool $registerCall = true
75
-	 */
76
-	public function __construct($app, $name, $renderAs = TemplateResponse::RENDER_AS_BLANK, $registerCall = true) {
77
-		// Read the selected theme from the config file
78
-		self::initTemplateEngine($renderAs);
79
-
80
-		$theme = OC_Util::getTheme();
81
-
82
-		$requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : '';
83
-
84
-		$parts = explode('/', $app); // fix translation when app is something like core/lostpassword
85
-		$l10n = \OC::$server->getL10N($parts[0]);
86
-		/** @var \OCP\Defaults $themeDefaults */
87
-		$themeDefaults = \OC::$server->query(\OCP\Defaults::class);
88
-
89
-		list($path, $template) = $this->findTemplate($theme, $app, $name);
90
-
91
-		// Set the private data
92
-		$this->renderAs = $renderAs;
93
-		$this->path = $path;
94
-		$this->app = $app;
95
-
96
-		parent::__construct($template, $requestToken, $l10n, $themeDefaults);
97
-	}
98
-
99
-	/**
100
-	 * @param string $renderAs
101
-	 */
102
-	public static function initTemplateEngine($renderAs) {
103
-		if (self::$initTemplateEngineFirstRun) {
104
-
105
-			//apps that started before the template initialization can load their own scripts/styles
106
-			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
107
-			//meaning the last script/style in this list will be loaded first
108
-			if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== TemplateResponse::RENDER_AS_ERROR && !\OCP\Util::needUpgrade()) {
109
-				if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
110
-					OC_Util::addScript('backgroundjobs', null, true);
111
-				}
112
-			}
113
-			OC_Util::addStyle('css-variables', null, true);
114
-			OC_Util::addStyle('server', null, true);
115
-			OC_Util::addTranslations('core', null, true);
116
-
117
-			if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
118
-				OC_Util::addScript('merged-template-prepend', null, true);
119
-				OC_Util::addScript('dist/files_client', null, true);
120
-				OC_Util::addScript('dist/files_fileinfo', null, true);
121
-			}
122
-			OC_Util::addScript('core', 'dist/main', true);
123
-
124
-			if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
125
-				// shim for the davclient.js library
126
-				\OCP\Util::addScript('dist/files_iedavclient');
127
-			}
128
-
129
-			self::$initTemplateEngineFirstRun = false;
130
-		}
131
-	}
132
-
133
-
134
-	/**
135
-	 * find the template with the given name
136
-	 * @param string $name of the template file (without suffix)
137
-	 *
138
-	 * Will select the template file for the selected theme.
139
-	 * Checking all the possible locations.
140
-	 * @param string $theme
141
-	 * @param string $app
142
-	 * @return string[]
143
-	 */
144
-	protected function findTemplate($theme, $app, $name) {
145
-		// Check if it is a app template or not.
146
-		if ($app !== '') {
147
-			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
148
-		} else {
149
-			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
150
-		}
151
-		$locator = new \OC\Template\TemplateFileLocator($dirs);
152
-		$template = $locator->find($name);
153
-		$path = $locator->getPath();
154
-		return [$path, $template];
155
-	}
156
-
157
-	/**
158
-	 * Add a custom element to the header
159
-	 * @param string $tag tag name of the element
160
-	 * @param array $attributes array of attributes for the element
161
-	 * @param string $text the text content for the element. If $text is null then the
162
-	 * element will be written as empty element. So use "" to get a closing tag.
163
-	 */
164
-	public function addHeader($tag, $attributes, $text = null) {
165
-		$this->headers[] = [
166
-			'tag' => $tag,
167
-			'attributes' => $attributes,
168
-			'text' => $text
169
-		];
170
-	}
171
-
172
-	/**
173
-	 * Process the template
174
-	 * @return string
175
-	 *
176
-	 * This function process the template. If $this->renderAs is set, it
177
-	 * will produce a full page.
178
-	 */
179
-	public function fetchPage($additionalParams = null) {
180
-		$data = parent::fetchPage($additionalParams);
181
-
182
-		if ($this->renderAs) {
183
-			$page = new TemplateLayout($this->renderAs, $this->app);
184
-
185
-			if (is_array($additionalParams)) {
186
-				foreach ($additionalParams as $key => $value) {
187
-					$page->assign($key, $value);
188
-				}
189
-			}
190
-
191
-			// Add custom headers
192
-			$headers = '';
193
-			foreach (OC_Util::$headers as $header) {
194
-				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
195
-				if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
196
-					$headers .= ' defer';
197
-				}
198
-				foreach ($header['attributes'] as $name => $value) {
199
-					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
200
-				}
201
-				if ($header['text'] !== null) {
202
-					$headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
203
-				} else {
204
-					$headers .= '/>';
205
-				}
206
-			}
207
-
208
-			$page->assign('headers', $headers);
209
-
210
-			$page->assign('content', $data);
211
-			return $page->fetchPage($additionalParams);
212
-		}
213
-
214
-		return $data;
215
-	}
216
-
217
-	/**
218
-	 * Include template
219
-	 *
220
-	 * @param string $file
221
-	 * @param array|null $additionalParams
222
-	 * @return string returns content of included template
223
-	 *
224
-	 * Includes another template. use <?php echo $this->inc('template'); ?> to
225
-	 * do this.
226
-	 */
227
-	public function inc($file, $additionalParams = null) {
228
-		return $this->load($this->path.$file.'.php', $additionalParams);
229
-	}
230
-
231
-	/**
232
-	 * Shortcut to print a simple page for users
233
-	 * @param string $application The application we render the template for
234
-	 * @param string $name Name of the template
235
-	 * @param array $parameters Parameters for the template
236
-	 * @return boolean|null
237
-	 */
238
-	public static function printUserPage($application, $name, $parameters = []) {
239
-		$content = new OC_Template($application, $name, "user");
240
-		foreach ($parameters as $key => $value) {
241
-			$content->assign($key, $value);
242
-		}
243
-		print $content->printPage();
244
-	}
245
-
246
-	/**
247
-	 * Shortcut to print a simple page for admins
248
-	 * @param string $application The application we render the template for
249
-	 * @param string $name Name of the template
250
-	 * @param array $parameters Parameters for the template
251
-	 * @return bool
252
-	 */
253
-	public static function printAdminPage($application, $name, $parameters = []) {
254
-		$content = new OC_Template($application, $name, "admin");
255
-		foreach ($parameters as $key => $value) {
256
-			$content->assign($key, $value);
257
-		}
258
-		return $content->printPage();
259
-	}
260
-
261
-	/**
262
-	 * Shortcut to print a simple page for guests
263
-	 * @param string $application The application we render the template for
264
-	 * @param string $name Name of the template
265
-	 * @param array|string $parameters Parameters for the template
266
-	 * @return bool
267
-	 */
268
-	public static function printGuestPage($application, $name, $parameters = []) {
269
-		$content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest');
270
-		foreach ($parameters as $key => $value) {
271
-			$content->assign($key, $value);
272
-		}
273
-		return $content->printPage();
274
-	}
275
-
276
-	/**
277
-	 * Print a fatal error page and terminates the script
278
-	 * @param string $error_msg The error message to show
279
-	 * @param string $hint An optional hint message - needs to be properly escape
280
-	 * @param int $statusCode
281
-	 * @suppress PhanAccessMethodInternal
282
-	 */
283
-	public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) {
284
-		if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
285
-			\OC_App::loadApp('theming');
286
-		}
287
-
288
-
289
-		if ($error_msg === $hint) {
290
-			// If the hint is the same as the message there is no need to display it twice.
291
-			$hint = '';
292
-		}
293
-
294
-		http_response_code($statusCode);
295
-		try {
296
-			$content = new \OC_Template('', 'error', 'error', false);
297
-			$errors = [['error' => $error_msg, 'hint' => $hint]];
298
-			$content->assign('errors', $errors);
299
-			$content->printPage();
300
-		} catch (\Exception $e) {
301
-			$logger = \OC::$server->getLogger();
302
-			$logger->error("$error_msg $hint", ['app' => 'core']);
303
-			$logger->logException($e, ['app' => 'core']);
304
-
305
-			header('Content-Type: text/plain; charset=utf-8');
306
-			print("$error_msg $hint");
307
-		}
308
-		die();
309
-	}
310
-
311
-	/**
312
-	 * print error page using Exception details
313
-	 * @param Exception|Throwable $exception
314
-	 * @param int $statusCode
315
-	 * @return bool|string
316
-	 * @suppress PhanAccessMethodInternal
317
-	 */
318
-	public static function printExceptionErrorPage($exception, $statusCode = 503) {
319
-		http_response_code($statusCode);
320
-		try {
321
-			$request = \OC::$server->getRequest();
322
-			$content = new \OC_Template('', 'exception', 'error', false);
323
-			$content->assign('errorClass', get_class($exception));
324
-			$content->assign('errorMsg', $exception->getMessage());
325
-			$content->assign('errorCode', $exception->getCode());
326
-			$content->assign('file', $exception->getFile());
327
-			$content->assign('line', $exception->getLine());
328
-			$content->assign('exception', $exception);
329
-			$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
330
-			$content->assign('remoteAddr', $request->getRemoteAddress());
331
-			$content->assign('requestID', $request->getId());
332
-			$content->printPage();
333
-		} catch (\Exception $e) {
334
-			try {
335
-				$logger = \OC::$server->getLogger();
336
-				$logger->logException($exception, ['app' => 'core']);
337
-				$logger->logException($e, ['app' => 'core']);
338
-			} catch (Throwable $e) {
339
-				// no way to log it properly - but to avoid a white page of death we send some output
340
-				header('Content-Type: text/plain; charset=utf-8');
341
-				print("Internal Server Error\n\n");
342
-				print("The server encountered an internal error and was unable to complete your request.\n");
343
-				print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
344
-				print("More details can be found in the server log.\n");
345
-
346
-				// and then throw it again to log it at least to the web server error log
347
-				throw $e;
348
-			}
349
-
350
-			header('Content-Type: text/plain; charset=utf-8');
351
-			print("Internal Server Error\n\n");
352
-			print("The server encountered an internal error and was unable to complete your request.\n");
353
-			print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
354
-			print("More details can be found in the server log.\n");
355
-		}
356
-		die();
357
-	}
51
+    /** @var string */
52
+    private $renderAs; // Create a full page?
53
+
54
+    /** @var string */
55
+    private $path; // The path to the template
56
+
57
+    /** @var array */
58
+    private $headers = []; //custom headers
59
+
60
+    /** @var string */
61
+    protected $app; // app id
62
+
63
+    protected static $initTemplateEngineFirstRun = true;
64
+
65
+    /**
66
+     * Constructor
67
+     *
68
+     * @param string $app app providing the template
69
+     * @param string $name of the template file (without suffix)
70
+     * @param string $renderAs If $renderAs is set, OC_Template will try to
71
+     *                         produce a full page in the according layout. For
72
+     *                         now, $renderAs can be set to "guest", "user" or
73
+     *                         "admin".
74
+     * @param bool $registerCall = true
75
+     */
76
+    public function __construct($app, $name, $renderAs = TemplateResponse::RENDER_AS_BLANK, $registerCall = true) {
77
+        // Read the selected theme from the config file
78
+        self::initTemplateEngine($renderAs);
79
+
80
+        $theme = OC_Util::getTheme();
81
+
82
+        $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : '';
83
+
84
+        $parts = explode('/', $app); // fix translation when app is something like core/lostpassword
85
+        $l10n = \OC::$server->getL10N($parts[0]);
86
+        /** @var \OCP\Defaults $themeDefaults */
87
+        $themeDefaults = \OC::$server->query(\OCP\Defaults::class);
88
+
89
+        list($path, $template) = $this->findTemplate($theme, $app, $name);
90
+
91
+        // Set the private data
92
+        $this->renderAs = $renderAs;
93
+        $this->path = $path;
94
+        $this->app = $app;
95
+
96
+        parent::__construct($template, $requestToken, $l10n, $themeDefaults);
97
+    }
98
+
99
+    /**
100
+     * @param string $renderAs
101
+     */
102
+    public static function initTemplateEngine($renderAs) {
103
+        if (self::$initTemplateEngineFirstRun) {
104
+
105
+            //apps that started before the template initialization can load their own scripts/styles
106
+            //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
107
+            //meaning the last script/style in this list will be loaded first
108
+            if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== TemplateResponse::RENDER_AS_ERROR && !\OCP\Util::needUpgrade()) {
109
+                if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
110
+                    OC_Util::addScript('backgroundjobs', null, true);
111
+                }
112
+            }
113
+            OC_Util::addStyle('css-variables', null, true);
114
+            OC_Util::addStyle('server', null, true);
115
+            OC_Util::addTranslations('core', null, true);
116
+
117
+            if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) {
118
+                OC_Util::addScript('merged-template-prepend', null, true);
119
+                OC_Util::addScript('dist/files_client', null, true);
120
+                OC_Util::addScript('dist/files_fileinfo', null, true);
121
+            }
122
+            OC_Util::addScript('core', 'dist/main', true);
123
+
124
+            if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
125
+                // shim for the davclient.js library
126
+                \OCP\Util::addScript('dist/files_iedavclient');
127
+            }
128
+
129
+            self::$initTemplateEngineFirstRun = false;
130
+        }
131
+    }
132
+
133
+
134
+    /**
135
+     * find the template with the given name
136
+     * @param string $name of the template file (without suffix)
137
+     *
138
+     * Will select the template file for the selected theme.
139
+     * Checking all the possible locations.
140
+     * @param string $theme
141
+     * @param string $app
142
+     * @return string[]
143
+     */
144
+    protected function findTemplate($theme, $app, $name) {
145
+        // Check if it is a app template or not.
146
+        if ($app !== '') {
147
+            $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
148
+        } else {
149
+            $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
150
+        }
151
+        $locator = new \OC\Template\TemplateFileLocator($dirs);
152
+        $template = $locator->find($name);
153
+        $path = $locator->getPath();
154
+        return [$path, $template];
155
+    }
156
+
157
+    /**
158
+     * Add a custom element to the header
159
+     * @param string $tag tag name of the element
160
+     * @param array $attributes array of attributes for the element
161
+     * @param string $text the text content for the element. If $text is null then the
162
+     * element will be written as empty element. So use "" to get a closing tag.
163
+     */
164
+    public function addHeader($tag, $attributes, $text = null) {
165
+        $this->headers[] = [
166
+            'tag' => $tag,
167
+            'attributes' => $attributes,
168
+            'text' => $text
169
+        ];
170
+    }
171
+
172
+    /**
173
+     * Process the template
174
+     * @return string
175
+     *
176
+     * This function process the template. If $this->renderAs is set, it
177
+     * will produce a full page.
178
+     */
179
+    public function fetchPage($additionalParams = null) {
180
+        $data = parent::fetchPage($additionalParams);
181
+
182
+        if ($this->renderAs) {
183
+            $page = new TemplateLayout($this->renderAs, $this->app);
184
+
185
+            if (is_array($additionalParams)) {
186
+                foreach ($additionalParams as $key => $value) {
187
+                    $page->assign($key, $value);
188
+                }
189
+            }
190
+
191
+            // Add custom headers
192
+            $headers = '';
193
+            foreach (OC_Util::$headers as $header) {
194
+                $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
195
+                if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
196
+                    $headers .= ' defer';
197
+                }
198
+                foreach ($header['attributes'] as $name => $value) {
199
+                    $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
200
+                }
201
+                if ($header['text'] !== null) {
202
+                    $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
203
+                } else {
204
+                    $headers .= '/>';
205
+                }
206
+            }
207
+
208
+            $page->assign('headers', $headers);
209
+
210
+            $page->assign('content', $data);
211
+            return $page->fetchPage($additionalParams);
212
+        }
213
+
214
+        return $data;
215
+    }
216
+
217
+    /**
218
+     * Include template
219
+     *
220
+     * @param string $file
221
+     * @param array|null $additionalParams
222
+     * @return string returns content of included template
223
+     *
224
+     * Includes another template. use <?php echo $this->inc('template'); ?> to
225
+     * do this.
226
+     */
227
+    public function inc($file, $additionalParams = null) {
228
+        return $this->load($this->path.$file.'.php', $additionalParams);
229
+    }
230
+
231
+    /**
232
+     * Shortcut to print a simple page for users
233
+     * @param string $application The application we render the template for
234
+     * @param string $name Name of the template
235
+     * @param array $parameters Parameters for the template
236
+     * @return boolean|null
237
+     */
238
+    public static function printUserPage($application, $name, $parameters = []) {
239
+        $content = new OC_Template($application, $name, "user");
240
+        foreach ($parameters as $key => $value) {
241
+            $content->assign($key, $value);
242
+        }
243
+        print $content->printPage();
244
+    }
245
+
246
+    /**
247
+     * Shortcut to print a simple page for admins
248
+     * @param string $application The application we render the template for
249
+     * @param string $name Name of the template
250
+     * @param array $parameters Parameters for the template
251
+     * @return bool
252
+     */
253
+    public static function printAdminPage($application, $name, $parameters = []) {
254
+        $content = new OC_Template($application, $name, "admin");
255
+        foreach ($parameters as $key => $value) {
256
+            $content->assign($key, $value);
257
+        }
258
+        return $content->printPage();
259
+    }
260
+
261
+    /**
262
+     * Shortcut to print a simple page for guests
263
+     * @param string $application The application we render the template for
264
+     * @param string $name Name of the template
265
+     * @param array|string $parameters Parameters for the template
266
+     * @return bool
267
+     */
268
+    public static function printGuestPage($application, $name, $parameters = []) {
269
+        $content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest');
270
+        foreach ($parameters as $key => $value) {
271
+            $content->assign($key, $value);
272
+        }
273
+        return $content->printPage();
274
+    }
275
+
276
+    /**
277
+     * Print a fatal error page and terminates the script
278
+     * @param string $error_msg The error message to show
279
+     * @param string $hint An optional hint message - needs to be properly escape
280
+     * @param int $statusCode
281
+     * @suppress PhanAccessMethodInternal
282
+     */
283
+    public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) {
284
+        if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
285
+            \OC_App::loadApp('theming');
286
+        }
287
+
288
+
289
+        if ($error_msg === $hint) {
290
+            // If the hint is the same as the message there is no need to display it twice.
291
+            $hint = '';
292
+        }
293
+
294
+        http_response_code($statusCode);
295
+        try {
296
+            $content = new \OC_Template('', 'error', 'error', false);
297
+            $errors = [['error' => $error_msg, 'hint' => $hint]];
298
+            $content->assign('errors', $errors);
299
+            $content->printPage();
300
+        } catch (\Exception $e) {
301
+            $logger = \OC::$server->getLogger();
302
+            $logger->error("$error_msg $hint", ['app' => 'core']);
303
+            $logger->logException($e, ['app' => 'core']);
304
+
305
+            header('Content-Type: text/plain; charset=utf-8');
306
+            print("$error_msg $hint");
307
+        }
308
+        die();
309
+    }
310
+
311
+    /**
312
+     * print error page using Exception details
313
+     * @param Exception|Throwable $exception
314
+     * @param int $statusCode
315
+     * @return bool|string
316
+     * @suppress PhanAccessMethodInternal
317
+     */
318
+    public static function printExceptionErrorPage($exception, $statusCode = 503) {
319
+        http_response_code($statusCode);
320
+        try {
321
+            $request = \OC::$server->getRequest();
322
+            $content = new \OC_Template('', 'exception', 'error', false);
323
+            $content->assign('errorClass', get_class($exception));
324
+            $content->assign('errorMsg', $exception->getMessage());
325
+            $content->assign('errorCode', $exception->getCode());
326
+            $content->assign('file', $exception->getFile());
327
+            $content->assign('line', $exception->getLine());
328
+            $content->assign('exception', $exception);
329
+            $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
330
+            $content->assign('remoteAddr', $request->getRemoteAddress());
331
+            $content->assign('requestID', $request->getId());
332
+            $content->printPage();
333
+        } catch (\Exception $e) {
334
+            try {
335
+                $logger = \OC::$server->getLogger();
336
+                $logger->logException($exception, ['app' => 'core']);
337
+                $logger->logException($e, ['app' => 'core']);
338
+            } catch (Throwable $e) {
339
+                // no way to log it properly - but to avoid a white page of death we send some output
340
+                header('Content-Type: text/plain; charset=utf-8');
341
+                print("Internal Server Error\n\n");
342
+                print("The server encountered an internal error and was unable to complete your request.\n");
343
+                print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
344
+                print("More details can be found in the server log.\n");
345
+
346
+                // and then throw it again to log it at least to the web server error log
347
+                throw $e;
348
+            }
349
+
350
+            header('Content-Type: text/plain; charset=utf-8');
351
+            print("Internal Server Error\n\n");
352
+            print("The server encountered an internal error and was unable to complete your request.\n");
353
+            print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
354
+            print("More details can be found in the server log.\n");
355
+        }
356
+        die();
357
+    }
358 358
 }
Please login to merge, or discard this patch.