13 return hash(
"sha256", implode(
"-", [
15 $this->config->getHost(),
16 $this->config->getPort(),
17 $this->config->getDatabase()
23 return "The database is populated with ILIAS-tables.";
33 if ($environment->getResource(Setup\Environment::RESOURCE_DATABASE)) {
37 new \ilDatabaseExistsObjective($this->config)
47 $db = $environment->
getResource(Setup\Environment::RESOURCE_DATABASE);
48 $io = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
53 $io->text(
"Default DB engine is {$default}");
58 $io->text(
"reading dump file, this may take a while...");
63 throw new Setup\UnachievableException(
64 "Cannot determine database default engine, must be InnoDB or MyISAM"
76 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
83 $probe_tables = [
'usr_data',
'object_data',
'object_reference'];
84 $number_of_probe_tables = count($probe_tables);
86 $number_of_tables = count($tables);
89 $number_of_tables > self::MIN_NUMBER_OF_ILIAS_TABLES
90 && count(array_intersect($tables, $probe_tables)) == $number_of_probe_tables;
99 $path_to_db_dump = $this->config->getPathToDBDump();
100 if (!is_file(realpath($path_to_db_dump)) ||
101 !is_readable(realpath($path_to_db_dump))) {
103 "Cannot read database dump file: $path_to_db_dump"
110 }
catch (Throwable
$e) {
112 "Cannot populate database with dump file: $path_to_db_dump. Query failed: $query wih message " .
$e->getMessage(
122 $handle = fopen($path_to_db_dump,
"r");
123 while (($line = fgets($handle)) !==
false) {
124 if (preg_match(
'/^--/', $line)) {
127 if (preg_match(
'/^\/\*/', $line)) {
132 if (!preg_match(
'/;$/', trim($line))) {
153 $db->
manipulate(
'SET default_storage_engine=InnoDB;');
157 $db->
manipulate(
'SET default_storage_engine=MyISAM;');
170 $r = $db->
query(
'SHOW ENGINES ');
174 if (
$d->Support ===
'DEFAULT') {
175 $default =
$d->Engine;
178 return strtolower($default);
179 }
catch (Throwable
$e) {
An exception for terminatinating execution or to throw for unit testing.
Signals that some goal won't be achievable by actions of the system ever.
const TYPE_PDO_MYSQL_MYISAM
const TYPE_PDO_MYSQL_INNODB
isApplicable(Setup\Environment $environment)
@inheritDoc
const MIN_NUMBER_OF_ILIAS_TABLES
isDatabasePopulated(ilDBInterface $db)
queryReader(string $path_to_db_dump)
getDefaultEngine(ilDBInterface $db)
readDumpFile(ilDBInterface $db)
getPreconditions(Setup\Environment $environment)
setDefaultEngine(ilDBInterface $db)
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
execute($stmt, $data=array())
query($query)
Run a (read-only) Query on the database.
prepareManip($a_query, $a_types=null)
manipulate($query)
Run a (write) Query on the database.
fetchObject($query_result)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...