ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilDatabaseMetricsCollectedObjective Class Reference
+ Inheritance diagram for ilDatabaseMetricsCollectedObjective:
+ Collaboration diagram for ilDatabaseMetricsCollectedObjective:

Protected Member Functions

 getTentativePreconditions (Setup\Environment $environment)
 
 collectFrom (Setup\Environment $environment, Setup\Metrics\Storage $storage)
 

Detailed Description

Member Function Documentation

◆ collectFrom()

ilDatabaseMetricsCollectedObjective::collectFrom ( Setup\Environment  $environment,
Setup\Metrics\Storage  $storage 
)
protected

PhpArrayIndexImmediatelyRewrittenInspection

Definition at line 37 of file class.ilDatabaseMetricsCollectedObjective.php.

References $client_id, $DIC, $GLOBALS, $ini, and ILIAS\UI\examples\MessageBox\Info\info().

37  : void
38  {
39  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
40  if ($client_ini) {
41  $storage->storeConfigText(
42  "type",
43  $client_ini->readVariable("db", "type") ?? "mysql",
44  "The storage backend that is used for the database."
45  );
46  $storage->storeConfigText(
47  "host",
48  $client_ini->readVariable("db", "host"),
49  "The host where the storage backend is located."
50  );
51  $storage->storeConfigText(
52  "port",
53  $client_ini->readVariable("db", "port"),
54  "The port where the storage backend is located at the host."
55  );
56  $storage->storeConfigText(
57  "name",
58  $client_ini->readVariable("db", "name"),
59  "The name of the database in the storage backend."
60  );
61  $storage->storeConfigText(
62  "user",
63  $client_ini->readVariable("db", "user"),
64  "The user to be used for the storage backend."
65  );
66  $storage->storeConfigText(
67  "pass",
68  PHP_SAPI === 'cli' ? $client_ini->readVariable("db", "pass") : '********',
69  "The password for the user for the storage backend."
70  );
71  }
72 
73 
74  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
75  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
76  if (!$db && !$ini) {
77  return;
78  }
79  $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID);
80 
81  // ATTENTION: This is a total abomination. It only exists to allow the db-
82  // update to run. This is a memento to the fact, that dependency injection
83  // is something we want. Currently, every component could just service
84  // locate the whole world via the global $DIC.
85  $DIC = $GLOBALS["DIC"] ?? [];
86  try {
87  $GLOBALS["DIC"] = new DI\Container();
88  $GLOBALS["DIC"]["ilDB"] = $db;
89  $GLOBALS["DIC"]["ilBench"] = null;
90  $GLOBALS["DIC"]["ilLog"] = new class () {
91  public function write(): void
92  {
93  }
94  public function info(): void
95  {
96  }
97  public function warning($msg): void
98  {
99  }
100  public function error($msg): void
101  {
102  }
103  };
105  $GLOBALS["DIC"]["ilLoggerFactory"] = new class () {
106  public function getRootLogger(): object
107  {
108  return new class () {
109  public function write(): void
110  {
111  }
112  };
113  }
114  };
115  if (!defined("CLIENT_DATA_DIR")) {
116  define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
117  }
118  if (!defined("CLIENT_WEB_DIR")) {
119  define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
120  }
121  if (!defined("ILIAS_ABSOLUTE_PATH")) {
122  define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
123  }
124  if (!defined("ILIAS_LOG_ENABLED")) {
125  define("ILIAS_LOG_ENABLED", false);
126  }
127  if (!defined("ROOT_FOLDER_ID")) {
128  define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
129  }
130  if (!defined("ROLE_FOLDER_ID")) {
131  define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
132  }
133  if (!defined("SYSTEM_FOLDER_ID")) {
134  define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
135  }
136 
137  $db_update = new ilDBUpdate($db);
138 
139  $storage->storeStableCounter(
140  "custom_version",
141  $db_update->getCustomUpdatesCurrentVersion() ?? 0,
142  "The version of the custom database schema that is currently installed."
143  );
144  $storage->storeStableCounter(
145  "available_custom_version",
146  $db_update->getCustomUpdatesFileVersion() ?? 0,
147  "The version of the custom database schema that is available in the current source."
148  );
149  $storage->storeStableBool(
150  "custom_update_required",
151  $db_update->customUpdatesAvailable(),
152  "Does the database require a custom update?"
153  );
154  } finally {
155  $GLOBALS["DIC"] = $DIC;
156  }
157  }
info()
description: > Example for rendering a info message box.
Definition: info.php:18
$GLOBALS["DIC"]
Definition: wac.php:30
global $DIC
Definition: shib_login.php:25
Database Update class.
$client_id
Definition: ltiauth.php:67
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:

◆ getTentativePreconditions()

ilDatabaseMetricsCollectedObjective::getTentativePreconditions ( Setup\Environment  $environment)
protected
Returns
array<|>

Definition at line 29 of file class.ilDatabaseMetricsCollectedObjective.php.

29  : array
30  {
31  return [
32  new \ilIniFilesLoadedObjective(),
33  new \ilDatabaseInitializedObjective()
34  ];
35  }

The documentation for this class was generated from the following file: