ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDatabaseMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6use ILIAS\DI;
7
9{
10 public function getTentativePreconditions(Setup\Environment $environment) : array
11 {
12 return [
13 new \ilIniFilesLoadedObjective(),
14 new \ilDatabaseInitializedObjective()
15 ];
16 }
17
18 public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage) : void
19 {
20 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
21 if ($client_ini) {
22 $storage->storeConfigText(
23 "type",
24 $client_ini->readVariable("db", "type") ?? "mysql",
25 "The storage backend that is used for the database."
26 );
27 $storage->storeConfigText(
28 "host",
29 $client_ini->readVariable("db", "host"),
30 "The host where the storage backend is located."
31 );
32 $storage->storeConfigText(
33 "port",
34 $client_ini->readVariable("db", "port"),
35 "The port where the storage backend is located at the host."
36 );
37 $storage->storeConfigText(
38 "name",
39 $client_ini->readVariable("db", "name"),
40 "The name of the database in the storage backend."
41 );
42 $storage->storeConfigText(
43 "user",
44 $client_ini->readVariable("db", "user"),
45 "The user to be used for the storage backend."
46 );
47 $storage->storeConfigText(
48 "pass",
49 PHP_SAPI === 'cli' ? $client_ini->readVariable("db", "pass") : '********',
50 "The password for the user for the storage backend."
51 );
52 }
53
54
55 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
56 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
57 if (!$db && !$ini) {
58 return;
59 }
60 $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
61
62 // ATTENTION: This is a total abomination. It only exists to allow the db-
63 // update to run. This is a memento to the fact, that dependency injection
64 // is something we want. Currently, every component could just service
65 // locate the whole world via the global $DIC.
66 $DIC = $GLOBALS["DIC"] ?? [];
67 $GLOBALS["DIC"] = new DI\Container();
68 $GLOBALS["DIC"]["ilDB"] = $db;
69 $GLOBALS["ilDB"] = $db;
70 $GLOBALS["DIC"]["ilBench"] = null;
71 $GLOBALS["DIC"]["ilLog"] = new class() {
72 public function write()
73 {
74 }
75 public function info()
76 {
77 }
78 public function warning($msg)
79 {
80 }
81 public function error($msg)
82 {
83 }
84 };
85 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
86 $GLOBALS["DIC"]["ilLoggerFactory"] = new class() {
87 public function getRootLogger()
88 {
89 return new class() {
90 public function write()
91 {
92 }
93 };
94 }
95 };
96 $GLOBALS["ilCtrlStructureReader"] = new class() {
97 public function getStructure()
98 {
99 }
100 public function setIniFile()
101 {
102 }
103 };
104 if (!defined("CLIENT_DATA_DIR")) {
105 define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
106 }
107 if (!defined("CLIENT_WEB_DIR")) {
108 define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
109 }
110 if (!defined("ILIAS_ABSOLUTE_PATH")) {
111 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
112 }
113 if (!defined("ILIAS_LOG_ENABLED")) {
114 define("ILIAS_LOG_ENABLED", false);
115 }
116 if (!defined("ROOT_FOLDER_ID")) {
117 define("ROOT_FOLDER_ID", $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
118 }
119 if (!defined("ROLE_FOLDER_ID")) {
120 define("ROLE_FOLDER_ID", $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
121 }
122 if (!defined("SYSTEM_FOLDER_ID")) {
123 define("SYSTEM_FOLDER_ID", $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
124 }
125
126 $db_update = new class($db, $client_ini) extends ilDBUpdate {
127 public function loadXMLInfo()
128 {
129 }
130 };
131 $db_update->readCustomUpdatesInfo(true);
132
133 $storage->storeStableCounter(
134 "version",
135 $db_update->getCurrentVersion(),
136 "The version of the database schema that is currently installed."
137 );
138 $storage->storeStableCounter(
139 "available_version",
140 $db_update->getFileVersion(),
141 "The version of the database schema that is available in the current source."
142 );
143 $storage->storeStableBool(
144 "update_required",
145 !$db_update->getDBVersionStatus(),
146 "Does the database require an update?"
147 );
148 $storage->storeStableCounter(
149 "hotfix_version",
150 $db_update->getHotfixCurrentVersion() ?? 0,
151 "The version of the hotfix database schema that is currently installed."
152 );
153 $storage->storeStableCounter(
154 "available_hotfix_version",
155 $db_update->getHotfixFileVersion() ?? 0,
156 "The version of the hotfix database schema that is available in the current source."
157 );
158 $storage->storeStableBool(
159 "hotfix_required",
160 $db_update->hotfixAvailable(),
161 "Does the database require a hotfix update?"
162 );
163 $storage->storeStableCounter(
164 "custom_version",
165 $db_update->getCustomUpdatesCurrentVersion() ?? 0,
166 "The version of the custom database schema that is currently installed."
167 );
168 $storage->storeStableCounter(
169 "available_custom_version",
170 $db_update->getCustomUpdatesFileVersion() ?? 0,
171 "The version of the custom database schema that is available in the current source."
172 );
173 $storage->storeStableBool(
174 "custom_update_required",
175 $db_update->customUpdatesAvailable(),
176 "Does the database require a custom update?"
177 );
178
179 $GLOBALS["DIC"] = $DIC;
180 }
181}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
error($a_errmsg)
set error message @access public
Database Update class.
readCustomUpdatesInfo($a_force=false)
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
global $DIC
Definition: goto.php:24
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4
info()
Definition: info.php:2
$client_id
Definition: webdav.php:17