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_03.php";
84 if ((
int)$a_version > 2948)
86 return "dbupdate_03.php";
88 else if ((
int)$a_version > 864)
90 return "dbupdate_02.php";
94 return "dbupdate.php";
113 $this->db->disconnect();
118 if (!file_exists($this->DB_UPDATE_FILE))
120 $this->error =
"no_db_update_file";
121 $this->filecontent = array();
125 $this->filecontent = @file($this->DB_UPDATE_FILE);
131 if (!file_exists($this->LAST_UPDATE_FILE))
133 $this->error =
"no_last_update_file";
134 $this->lastfilecontent = array();
138 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
145 include_once
'./Services/Administration/classes/class.ilSetting.php';
147 $this->currentVersion = (integer) $set->get(
"db_version");
153 include_once
'./Services/Administration/classes/class.ilSetting.php';
155 $set->set(
"db_version", $a_version);
156 $this->currentVersion = $a_version;
168 include_once
'./Services/Administration/classes/class.ilSetting.php';
170 $set->set(
"db_update_running", $a_nr);
171 $this->db_update_running = $a_nr;
181 include_once
'./Services/Administration/classes/class.ilSetting.php';
183 $this->db_update_running = (integer) $set->get(
"db_update_running");
185 return $this->db_update_running;
193 include_once
'./Services/Administration/classes/class.ilSetting.php';
195 $set->set(
"db_update_running", 0);
196 $this->db_update_running = 0;
202 reset($this->lastfilecontent);
204 foreach ($this->lastfilecontent as
$row)
206 if (ereg(
"^<#([0-9]+)>", $row, $regs))
212 $this->fileVersion = (integer) $version;
232 $sql = explode(
"\n",trim($str));
233 for ($i=0; $i<count($sql); $i++)
235 $sql[$i] = trim($sql[$i]);
236 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
239 if (substr($sql[$i],-1)==
";")
242 $q .=
" ".substr($sql[$i],0,-1);
249 $this->error = $r->getMessage();
255 $this->error = $check;
268 echo
"incomplete_statement: ".$q.
"<br>";
289 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
292 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
297 if ($a_break > $this->currentVersion &&
298 $a_break < $this->fileVersion)
306 for ($i=($c+1); $i<=$f; $i++)
311 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
320 "msg" =>
"update_error: ".$this->error,
323 $this->updateMsg = $msg;
329 "msg" =>
"update_applied",
335 $this->updateMsg = $msg;
339 $this->updateMsg =
"no_changes";
342 if ($f < $this->fileVersion)
357 require_once
"./setup/classes/class.ilModuleReader.php";
358 require_once
"./setup/classes/class.ilServiceReader.php";
359 require_once
"./setup/classes/class.ilCtrlStructureReader.php";
361 require_once
"./Services/Component/classes/class.ilModule.php";
362 require_once
"./Services/Component/classes/class.ilService.php";
367 foreach($modules as $module)
370 $module[
"subdir"],
"Modules");
376 foreach($services as $service)
379 $service[
"subdir"],
"Services");
384 $ilCtrlStructureReader->readStructure();
400 reset($this->filecontent);
411 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
417 if ($i == count($this->filecontent))
419 $this->error =
"update_not_found";
427 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
429 $update[] = trim($this->filecontent[$i]);
438 foreach ($update as
$row)
440 if (ereg(
"<\?php", $row))
444 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
446 $this->error = $this->error;
453 elseif (ereg(
"\?>", $row))
457 $code = implode(
"\n", $php);
458 if (eval($code) ===
false)
460 $this->error =
"Parse error: ".$code;
482 if ($mode ==
"sql" && count($sql) > 0)
484 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
486 $this->error =
"dump_error: ".$this->error;
513 if ($this->fileVersion > $this->currentVersion)
529 "name" => $status[
"Table"],
531 "status" => $status[
"Msg_text"]
541 $query =
"ANALYZE TABLE ".$table;
550 foreach (
$_POST[
"tables"] as $key => $value)
552 $query =
"OPTIMIZE TABLE ".$key;
554 $msg[] =
"table $key: ok";
570 return $this->hotfix_current_version;
579 $this->hotfix_setting->set(
"db_hotfixes_".
580 $this->hotfix_version[0].
"_".$this->hotfix_version[1], $a_version);
581 $this->hotfix_current_version = $a_version;
591 return $this->hotfix_file_version;
600 reset($a_file_content);
602 foreach ($a_file_content as
$row)
604 if (ereg(
"^<#([0-9]+)>", $row, $regs))
610 return (integer) $version;
618 if ($this->hotfix_info_read && !$a_force)
622 include_once
'./Services/Administration/classes/class.ilSetting.php';
624 $this->hotfix_setting =
new ilSetting(
"common",
true);
626 $version_array = explode(
".", $ilias_version);
627 $this->hotfix_version[0] = $version_array[0];
628 $this->hotfix_version[1] = $version_array[1];
629 $hotfix_file = $this->PATH.
"setup/sql/".$this->hotfix_version[0].
"_".$this->hotfix_version[1].
"_hotfixes.php";
630 if (is_file($hotfix_file))
632 $this->hotfix_content = @file($hotfix_file);
633 $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_".
634 $this->hotfix_version[0].
"_".$this->hotfix_version[1]);
637 $this->hotfix_info_read =
true;
646 if ($this->hotfix_file_version > $this->hotfix_current_version)
660 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
663 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
673 for ($i=($c+1); $i<=$f; $i++)
677 $this->filecontent = $this->hotfix_content;
682 "msg" =>
"update_error: ".$this->error,
685 $this->updateMsg = $msg;
691 "msg" =>
"hotfix_applied",
697 $this->updateMsg = $msg;
701 $this->updateMsg =
"no_changes";