ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
error.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Init;
22
23try {
24 require_once '../vendor/composer/vendor/autoload.php';
25
26 require_once __DIR__ . '/../artifacts/bootstrap_default.php';
27 entry_point('ILIAS Legacy Initialisation Adapter');
28
29 $DIC->globalScreen()->tool()->context()->claim()->external();
30
31 $lng->loadLanguageModule('error');
32 $txt = $lng->txt('error_back_to_repository');
33
34 $local_tpl = new \ilGlobalTemplate('tpl.error.html', true, true);
35 $local_tpl->setCurrentBlock('ErrorLink');
36 $local_tpl->setVariable('TXT_LINK', $txt);
37 $local_tpl->setVariable('LINK', \ilUtil::secureUrl(ILIAS_HTTP_PATH . '/ilias.php?baseClass=ilRepositoryGUI'));
38 $local_tpl->parseCurrentBlock();
39
40 \ilSession::clear('referer');
41 \ilSession::clear('message');
42
43 $DIC->http()->saveResponse(
44 $DIC->http()
45 ->response()
46 ->withStatus(500)
47 ->withHeader(\ILIAS\HTTP\Response\ResponseHeader::CONTENT_TYPE, 'text/html')
48 );
49
50 $tpl->setContent($local_tpl->get());
51 $tpl->printToStdout();
52
53 $DIC->http()->close();
54} catch (\Throwable $e) {
55 if (\defined('DEVMODE') && DEVMODE) {
56 throw $e;
57 }
58
59 /*
60 * Since we are already in the `error.php` and an unexpected error occurred, we should not rely on the $DIC or any
61 * other components here and use "Vanilla PHP" instead to handle the error.
62 */
63 if (!headers_sent()) {
64 http_response_code(500);
65 header('Content-Type: text/plain; charset=UTF-8');
66 }
67
68 $incident_id = session_id() . '_' . (new \Random\Randomizer())->getInt(1, 9999);
69 $timestamp = (new \DateTimeImmutable())->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');
70
71 echo "Internal Server Error\n";
72 echo "Incident: $incident_id\n";
73 echo "Timestamp: $timestamp\n";
74 if ($e instanceof \PDOException) {
75 echo "Message: A database error occurred. Please contact the system administrator with the incident id.\n";
76 } else {
77 echo "Message: {$e->getMessage()}\n";
78 }
79
80 error_log(\sprintf(
81 "[%s] INCIDENT %s — Uncaught %s: %s in %s:%d\nStack trace:\n%s\n",
83 $incident_id,
84 \get_class($e),
85 $e->getMessage(),
86 $e->getFile(),
87 $e->getLine(),
88 $e->getTraceAsString()
89 ));
90
91 exit(1);
92}
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
$local_tpl
Definition: error.php:34
static clear(string $a_var)
static secureUrl(string $url)
exit
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
entry_point(string $name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: result1.php:21
global $DIC
Definition: shib_login.php:26