ILIAS  release_8 Revision v8.24
class.ilDatabaseUpdatedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22use ILIAS\DI;
23
25{
26 public function getHash(): string
27 {
28 return hash("sha256", self::class);
29 }
30
31 public function getLabel(): string
32 {
33 return "The database is updated.";
34 }
35
36 public function isNotable(): bool
37 {
38 return true;
39 }
40
44 public function getPreconditions(Setup\Environment $environment): array
45 {
46 $preconditions = [];
47 $preconditions[] = new Setup\Objective\ClientIdReadObjective();
48 $preconditions[] = new ilIniFilesPopulatedObjective();
49 $preconditions[] = new ilDatabaseInitializedObjective();
50
51 return $preconditions;
52 }
53
54 public function achieve(Setup\Environment $environment): Setup\Environment
55 {
56 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
57 $io = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
58 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
59 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
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.
67 $DIC = $GLOBALS["DIC"] ?? [];
68 $GLOBALS["DIC"] = new DI\Container();
69 $GLOBALS["DIC"]["ilDB"] = $db;
70 $GLOBALS["ilDB"] = $db;
71 $GLOBALS["DIC"]["ilBench"] = null;
72 $GLOBALS["DIC"]["ilLog"] = new class ($io) {
73 public function __construct($io)
74 {
75 $this->io = $io;
76 }
77
78 public function write(): void
79 {
80 }
81
82 public function info(): void
83 {
84 }
85
86 public function warning($msg): void
87 {
88 $this->io->inform($msg);
89 }
90
91 public function error($msg): void
92 {
94 "Problem in DB-Update: $msg"
95 );
96 }
97 };
98 $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"];
99 $GLOBALS["DIC"]["ilLoggerFactory"] = new class () {
100 public function getRootLogger(): object
101 {
102 return new class () {
103 public function write(): void
104 {
105 }
106 };
107 }
108 };
109 $GLOBALS["ilCtrlStructureReader"] = new class () {
110 public function getStructure(): void
111 {
112 }
113
114 public function setIniFile(): void
115 {
116 }
117 };
118 if (!defined("CLIENT_DATA_DIR")) {
119 define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id);
120 }
121 if (!defined("CLIENT_WEB_DIR")) {
122 define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
123 }
124 if (!defined("ILIAS_ABSOLUTE_PATH")) {
125 define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
126 }
127 if (!defined("ILIAS_LOG_ENABLED")) {
128 define("ILIAS_LOG_ENABLED", false);
129 }
130 if (!defined("ROOT_FOLDER_ID")) {
131 define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID"));
132 }
133 if (!defined("ROLE_FOLDER_ID")) {
134 define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID"));
135 }
136 if (!defined("SYSTEM_FOLDER_ID")) {
137 define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID"));
138 }
139
140 $db_update = new ilDBUpdate($db);
141
142 $db_update->applyUpdate();
143 $db_update->applyHotfix();
144 $db_update->applyCustomUpdates();
145
146 $GLOBALS["DIC"] = $DIC;
147
148 return $environment;
149 }
150
154 public function isApplicable(Setup\Environment $environment): bool
155 {
156 return true;
157 }
158}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Read the client id of the installation from the data directory.
Signals that some goal won't be achievable by actions of the system ever.
error(string $a_errmsg)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
achieve(Setup\Environment $environment)
getPreconditions(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
@inheritDoc
global $DIC
Definition: feed.php:28
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.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$client_id
Definition: ltiauth.php:68
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Container.php:19
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4