19 declare(strict_types=1);
33 return hash(
"sha256", implode(
"-", [
35 $this->config->getHost(),
36 $this->config->getPort(),
37 $this->config->getDatabase()
43 return "The database is populated with ILIAS-tables.";
56 if ($environment->
hasConfigFor(InstallCommand::IMPORT)) {
62 if ($environment->
getResource(Environment::RESOURCE_DATABASE)) {
66 new \ilDatabaseExistsObjective($this->config)
76 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
77 $io = $environment->
getResource(Environment::RESOURCE_ADMIN_INTERACTION);
82 $io->text(
"Default DB engine is $default");
87 $io->text(
"reading dump file, this may take a while...");
93 "Cannot determine database default engine, must be InnoDB, `$default` given." 105 if ($environment->
hasConfigFor(InstallCommand::IMPORT)) {
109 $db = $environment->
getResource(Environment::RESOURCE_DATABASE);
116 $probe_tables = [
'usr_data',
'object_data',
'object_reference'];
117 $number_of_probe_tables = count($probe_tables);
119 $number_of_tables = count($tables);
122 $number_of_tables > self::MIN_NUMBER_OF_ILIAS_TABLES
123 && count(array_intersect($tables, $probe_tables)) === $number_of_probe_tables;
131 $path_to_db_dump = $this->config->getPathToDBDump();
132 if (!is_file(realpath($path_to_db_dump) ?:
'') ||
133 !is_readable(realpath($path_to_db_dump) ?:
'')) {
135 "Cannot read database dump file: $path_to_db_dump" 138 foreach ($this->
queryReader(realpath($path_to_db_dump)) as $query) {
144 "Cannot populate database with dump file: $path_to_db_dump. Query failed: $query wih message " . $e->getMessage(
154 $handle = fopen($path_to_db_dump,
"r");
155 while (($line = fgets($handle)) !==
false) {
156 if (preg_match(
'/^--/', $line)) {
159 if (preg_match(
'/^\/\*/', $line)) {
164 if (!preg_match(
'/;$/', trim($line))) {
183 case 'pdo-mysql-innodb':
187 $db->
manipulate(
'SET default_storage_engine=InnoDB;');
195 $r = $db->
query(
'SHOW ENGINES ');
199 if (strtoupper((
string)
$d->Support) ===
'DEFAULT') {
200 $default =
$d->Engine;
204 return strtolower((
string) $default);
getPreconditions(Environment $environment)
getLabel()
Get a label that describes this objective.
setDefaultEngine(ilDBInterface $db)
queryReader(string $path_to_db_dump)
getHash()
Get a hash for this objective.
readDumpFile(ilDBInterface $db)
getDefaultEngine(ilDBInterface $db)
A wrapper around an objective that adds some preconditions.
execute(ilDBStatement $stmt, array $data=[])
Signals that some goal won't be achievable by actions of the system ever.
isDatabasePopulated(ilDBInterface $db)
fetchObject(ilDBStatement $query_result)
const MIN_NUMBER_OF_ILIAS_TABLES
query(string $query)
Run a (read-only) Query on the database.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
isApplicable(Environment $environment)
achieve(Environment $environment)
Objectives can be achieved.
isNotable()
Get to know if this is an interesting objective for a human.
prepareManip(string $a_query, ?array $a_types=null)
An environment holds resources to be used in the setup process.
hasConfigFor(string $component)
getConfigFor(string $component)
manipulate(string $query)
Run a (write) Query on the database.