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