ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDatabaseMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
27{
31 protected function getTentativePreconditions(Environment $environment): array
32 {
33 return [
34 new \ilIniFilesLoadedObjective(),
35 new \ilDatabaseInitializedObjective()
36 ];
37 }
38
39 protected function collectFrom(Environment $environment, Storage $storage): void
40 {
41 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
42 if ($client_ini) {
44 "type",
45 $client_ini->readVariable("db", "type") ?? "mysql",
46 "The storage backend that is used for the database."
47 );
49 "host",
50 $client_ini->readVariable("db", "host"),
51 "The host where the storage backend is located."
52 );
54 "port",
55 $client_ini->readVariable("db", "port"),
56 "The port where the storage backend is located at the host."
57 );
59 "name",
60 $client_ini->readVariable("db", "name"),
61 "The name of the database in the storage backend."
62 );
64 "user",
65 $client_ini->readVariable("db", "user"),
66 "The user to be used for the storage backend."
67 );
69 "pass",
70 PHP_SAPI === 'cli' ? $client_ini->readVariable("db", "pass") : '********',
71 "The password for the user for the storage backend."
72 );
73 }
74
75
76 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
77 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
78 if (!$db && !$ini) {
79 return;
80 }
81 $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
82
83 // ATTENTION: This is a total abomination. It only exists to allow the db-
84 // update to run. This is a memento to the fact, that dependency injection
85 // is something we want. Currently, every component could just service
86 // locate the whole world via the global $DIC.
87 $DIC = $GLOBALS["DIC"] ?? [];
88 try {
89 $GLOBALS["DIC"] = new Container();
90 $GLOBALS["DIC"]["ilDB"] = $db;
91 $GLOBALS["DIC"]["ilBench"] = null;
92 $GLOBALS["DIC"]["ilLog"] = new class () {
93 public function write(): void
94 {
95 }
96 public function info(): void
97 {
98 }
99 public function warning($msg): void
100 {
101 }
102 public function error($msg): void
103 {
104 }
105 };
107 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () {
108 public function getRootLogger(): object
109 {
110 return new class () {
111 public function write(): void
112 {
113 }
114 };
115 }
116 };
117 if (!defined("CLIENT_DATA_DIR")) {
118 define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
119 }
120 if (!defined("CLIENT_WEB_DIR")) {
121 define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
122 }
123 if (!defined("ILIAS_ABSOLUTE_PATH")) {
124 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
125 }
126 if (!defined("ILIAS_LOG_ENABLED")) {
127 define("ILIAS_LOG_ENABLED", false);
128 }
129 if (!defined("ROOT_FOLDER_ID")) {
130 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
131 }
132 if (!defined("ROLE_FOLDER_ID")) {
133 define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
134 }
135 if (!defined("SYSTEM_FOLDER_ID")) {
136 define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
137 }
138
139 $db_update = new ilDBUpdate($db);
140
142 "custom_version",
143 $db_update->getCustomUpdatesCurrentVersion() ?? 0,
144 "The version of the custom database schema that is currently installed."
145 );
147 "available_custom_version",
148 $db_update->getCustomUpdatesFileVersion() ?? 0,
149 "The version of the custom database schema that is available in the current source."
150 );
152 "custom_update_required",
153 $db_update->customUpdatesAvailable(),
154 "Does the database require a custom update?"
155 );
156 } finally {
157 $GLOBALS["DIC"] = $DIC;
158 }
159 }
160}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Base class to simplify collection of metrics.
error(string $a_errmsg)
Database Update class.
collectFrom(Environment $environment, Storage $storage)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
storeStableBool(string $key, bool $value, ?string $description=null)
storeConfigText(string $key, string $value, ?string $description=null)
storeStableCounter(string $key, int $value, ?string $description=null)
$client_id
Definition: ltiauth.php:67
$ini
Definition: raiseError.php:20
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54