39 $this->db =& $a_db_handler;
54 $this->db = $mySetup->db;
63 $this->current_file = $updatefile;
64 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$updatefile;
69 $this->LAST_UPDATE_FILE = $this->PATH.
"setup/sql/dbupdate_02.php";
84 if ((
int)$a_version > 864)
86 return "dbupdate_02.php";
90 return "dbupdate.php";
109 $this->db->disconnect();
114 if (!file_exists($this->DB_UPDATE_FILE))
116 $this->error =
"no_db_update_file";
117 $this->filecontent = array();
121 $this->filecontent = @file($this->DB_UPDATE_FILE);
127 if (!file_exists($this->LAST_UPDATE_FILE))
129 $this->error =
"no_last_update_file";
130 $this->lastfilecontent = array();
134 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
141 include_once
'./Services/Administration/classes/class.ilSetting.php';
143 $this->currentVersion = (integer) $set->get(
"db_version");
150 include_once
'./Services/Administration/classes/class.ilSetting.php';
152 $set->set(
"db_version", $a_version);
153 $this->currentVersion = $a_version;
165 include_once
'./Services/Administration/classes/class.ilSetting.php';
167 $set->set(
"db_update_running", $a_nr);
168 $this->db_update_running = $a_nr;
178 include_once
'./Services/Administration/classes/class.ilSetting.php';
180 $this->db_update_running = (integer) $set->get(
"db_update_running");
182 return $this->db_update_running;
190 include_once
'./Services/Administration/classes/class.ilSetting.php';
192 $set->set(
"db_update_running", 0);
193 $this->db_update_running = 0;
199 reset($this->lastfilecontent);
201 foreach ($this->lastfilecontent as
$row)
203 if (ereg(
"^<#([0-9]+)>", $row, $regs))
209 $this->fileVersion = (integer) $version;
229 $sql = explode(
"\n",trim($str));
230 for ($i=0; $i<count($sql); $i++)
232 $sql[$i] = trim($sql[$i]);
233 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
236 if (substr($sql[$i],-1)==
";")
239 $q .=
" ".substr($sql[$i],0,-1);
246 $this->error = $r->getMessage();
252 $this->error = $check;
265 echo
"incomplete_statement: ".$q.
"<br>";
286 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
289 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
294 if ($a_break > $this->currentVersion &&
295 $a_break < $this->fileVersion)
303 for ($i=($c+1); $i<=
$f; $i++)
308 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
317 "msg" =>
"update_error: ".$this->error,
320 $this->updateMsg = $msg;
326 "msg" =>
"update_applied",
332 $this->updateMsg = $msg;
336 $this->updateMsg =
"no_changes";
339 if ($f < $this->fileVersion)
354 require_once
"./setup/classes/class.ilModuleReader.php";
355 require_once
"./setup/classes/class.ilServiceReader.php";
356 require_once
"./setup/classes/class.ilCtrlStructureReader.php";
358 require_once
"./Services/Component/classes/class.ilModule.php";
359 require_once
"./Services/Component/classes/class.ilService.php";
364 foreach($modules as $module)
367 $module[
"subdir"],
"Modules");
373 foreach($services as $service)
376 $service[
"subdir"],
"Services");
381 $ilCtrlStructureReader->readStructure();
397 reset($this->filecontent);
408 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
414 if ($i == count($this->filecontent))
416 $this->error =
"update_not_found";
424 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
426 $update[] = trim($this->filecontent[$i]);
435 foreach ($update as
$row)
437 if (ereg(
"<\?php", $row))
441 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
450 elseif (ereg(
"\?>", $row))
454 $code = implode(
"\n", $php);
475 if ($mode ==
"sql" && count($sql) > 0)
477 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
479 $this->error =
"dump_error: ".$this->error;
506 if ($this->fileVersion > $this->currentVersion)
522 "name" => $status[
"Table"],
524 "status" => $status[
"Msg_text"]
534 $query =
"ANALYZE TABLE ".$table;
545 $query =
"OPTIMIZE TABLE ".$key;
547 $msg[] =
"table $key: ok";
563 return $this->hotfix_current_version;
572 $this->hotfix_setting->set(
"db_hotfixes_".
573 $this->hotfix_version[0].
"_".$this->hotfix_version[1], $a_version);
574 $this->hotfix_current_version = $a_version;
584 return $this->hotfix_file_version;
593 reset($a_file_content);
595 foreach ($a_file_content as
$row)
597 if (ereg(
"^<#([0-9]+)>", $row, $regs))
603 return (integer) $version;
611 if ($this->hotfix_info_read && !$a_force)
615 include_once
'./Services/Administration/classes/class.ilSetting.php';
619 $version_array = explode(
".", $ilias_version);
620 $this->hotfix_version[0] = $version_array[0];
621 $this->hotfix_version[1] = $version_array[1];
622 $hotfix_file = $this->PATH.
"setup/sql/".$this->hotfix_version[0].
"_".$this->hotfix_version[1].
"_hotfixes.php";
623 if (is_file($hotfix_file))
625 $this->hotfix_content = @file($hotfix_file);
626 $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_".
627 $this->hotfix_version[0].
"_".$this->hotfix_version[1]);
630 $this->hotfix_info_read =
true;
639 if ($this->hotfix_file_version > $this->hotfix_current_version)
653 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
656 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
666 for ($i=($c+1); $i<=
$f; $i++)
670 $this->filecontent = $this->hotfix_content;
675 "msg" =>
"update_error: ".$this->error,
678 $this->updateMsg = $msg;
684 "msg" =>
"hotfix_applied",
690 $this->updateMsg = $msg;
694 $this->updateMsg =
"no_changes";