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)
41 public function achieve(Setup\
Environment $environment) : Setup\Environment
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))) {
102 throw new Setup\UnachievableException(
103 "Cannot read database dump file: $path_to_db_dump" 111 throw new Setup\UnachievableException(
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);
prepareManip($a_query, $a_types=null)
getPreconditions(Setup\Environment $environment)
execute($stmt, $data=array())
setDefaultEngine(ilDBInterface $db)
queryReader(string $path_to_db_dump)
readDumpFile(ilDBInterface $db)
getDefaultEngine(ilDBInterface $db)
const TYPE_PDO_MYSQL_INNODB
const TYPE_PDO_MYSQL_MYISAM
isDatabasePopulated(ilDBInterface $db)
const MIN_NUMBER_OF_ILIAS_TABLES
fetchObject($query_result)
isApplicable(Setup\Environment $environment)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
query($query)
Run a (read-only) Query on the database.
manipulate($query)
Run a (write) Query on the database.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d