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");
154 include_once
'./Services/Administration/classes/class.ilSetting.php';
156 $set->set(
"db_version", $a_version);
157 $this->currentVersion = $a_version;
169 include_once
'./Services/Administration/classes/class.ilSetting.php';
171 $set->set(
"db_update_running", $a_nr);
172 $this->db_update_running = $a_nr;
182 include_once
'./Services/Administration/classes/class.ilSetting.php';
184 $this->db_update_running = (integer) $set->get(
"db_update_running");
186 return $this->db_update_running;
194 include_once
'./Services/Administration/classes/class.ilSetting.php';
196 $set->set(
"db_update_running", 0);
197 $this->db_update_running = 0;
203 reset($this->lastfilecontent);
205 foreach ($this->lastfilecontent as
$row)
207 if (ereg(
"^<#([0-9]+)>", $row, $regs))
213 $this->fileVersion = (integer) $version;
233 $sql = explode(
"\n",trim($str));
234 for ($i=0; $i<count($sql); $i++)
236 $sql[$i] = trim($sql[$i]);
237 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
240 if (substr($sql[$i],-1)==
";")
243 $q .=
" ".substr($sql[$i],0,-1);
250 $this->error = $r->getMessage();
256 $this->error = $check;
269 echo
"incomplete_statement: ".$q.
"<br>";
290 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
293 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
298 if ($a_break > $this->currentVersion &&
299 $a_break < $this->fileVersion)
307 for ($i=($c+1); $i<=
$f; $i++)
312 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
321 "msg" =>
"update_error: ".$this->error,
324 $this->updateMsg = $msg;
330 "msg" =>
"update_applied",
336 $this->updateMsg = $msg;
340 $this->updateMsg =
"no_changes";
343 if ($f < $this->fileVersion)
358 require_once
"./setup/classes/class.ilModuleReader.php";
359 require_once
"./setup/classes/class.ilServiceReader.php";
360 require_once
"./setup/classes/class.ilCtrlStructureReader.php";
362 require_once
"./Services/Component/classes/class.ilModule.php";
363 require_once
"./Services/Component/classes/class.ilService.php";
368 foreach($modules as $module)
371 $module[
"subdir"],
"Modules");
377 foreach($services as $service)
380 $service[
"subdir"],
"Services");
385 $ilCtrlStructureReader->readStructure();
401 reset($this->filecontent);
412 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
418 if ($i == count($this->filecontent))
420 $this->error =
"update_not_found";
428 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
430 $update[] = trim($this->filecontent[$i]);
439 foreach ($update as
$row)
441 if (ereg(
"<\?php", $row))
445 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
454 elseif (ereg(
"\?>", $row))
458 $code = implode(
"\n", $php);
459 if (eval($code) ===
false)
461 $this->error =
"Parse error: ".$code;
483 if ($mode ==
"sql" && count($sql) > 0)
485 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
487 $this->error =
"dump_error: ".$this->error;
514 if ($this->fileVersion > $this->currentVersion)
530 "name" => $status[
"Table"],
532 "status" => $status[
"Msg_text"]
542 $query =
"ANALYZE TABLE ".$table;
551 foreach (
$_POST[
"tables"] as $key => $value)
553 $query =
"OPTIMIZE TABLE ".$key;
555 $msg[] =
"table $key: ok";
571 return $this->hotfix_current_version;
580 $this->hotfix_setting->set(
"db_hotfixes_".
581 $this->hotfix_version[0].
"_".$this->hotfix_version[1], $a_version);
582 $this->hotfix_current_version = $a_version;
592 return $this->hotfix_file_version;
601 reset($a_file_content);
603 foreach ($a_file_content as
$row)
605 if (ereg(
"^<#([0-9]+)>", $row, $regs))
611 return (integer) $version;
619 if ($this->hotfix_info_read && !$a_force)
623 include_once
'./Services/Administration/classes/class.ilSetting.php';
627 $version_array = explode(
".", $ilias_version);
628 $this->hotfix_version[0] = $version_array[0];
629 $this->hotfix_version[1] = $version_array[1];
630 $hotfix_file = $this->PATH.
"setup/sql/".$this->hotfix_version[0].
"_".$this->hotfix_version[1].
"_hotfixes.php";
631 if (is_file($hotfix_file))
633 $this->hotfix_content = @file($hotfix_file);
634 $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_".
635 $this->hotfix_version[0].
"_".$this->hotfix_version[1]);
638 $this->hotfix_info_read =
true;
647 if ($this->hotfix_file_version > $this->hotfix_current_version)
661 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
664 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
674 for ($i=($c+1); $i<=
$f; $i++)
678 $this->filecontent = $this->hotfix_content;
683 "msg" =>
"update_error: ".$this->error,
686 $this->updateMsg = $msg;
692 "msg" =>
"hotfix_applied",
698 $this->updateMsg = $msg;
702 $this->updateMsg =
"no_changes";