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_04.php";
84 if ((
int)$a_version > 4182)
86 return "dbupdate_04.php";
88 else if ((
int)$a_version > 2948)
90 return "dbupdate_03.php";
92 else if ((
int)$a_version > 864)
94 return "dbupdate_02.php";
98 return "dbupdate.php";
113 if (!file_exists($this->DB_UPDATE_FILE))
115 $this->error =
"no_db_update_file";
116 $this->filecontent =
array();
120 $this->filecontent = @
file($this->DB_UPDATE_FILE);
126 if (!file_exists($this->LAST_UPDATE_FILE))
128 $this->error =
"no_last_update_file";
129 $this->lastfilecontent =
array();
133 $this->lastfilecontent = @
file($this->LAST_UPDATE_FILE);
139 include_once
'./Services/Administration/classes/class.ilSetting.php';
141 $this->currentVersion = (integer) $set->get(
"db_version");
147 include_once
'./Services/Administration/classes/class.ilSetting.php';
149 $set->set(
"db_version", $a_version);
150 $this->currentVersion = $a_version;
162 include_once
'./Services/Administration/classes/class.ilSetting.php';
164 $set->set(
"db_update_running", $a_nr);
165 $this->db_update_running = $a_nr;
175 include_once
'./Services/Administration/classes/class.ilSetting.php';
177 $this->db_update_running = (integer) $set->get(
"db_update_running");
179 return $this->db_update_running;
187 include_once
'./Services/Administration/classes/class.ilSetting.php';
189 $set->set(
"db_update_running", 0);
190 $this->db_update_running = 0;
196 reset($this->lastfilecontent);
198 foreach ($this->lastfilecontent as
$row)
200 if (preg_match(
'/^<\#([0-9]+)>/', $row, $regs))
206 $this->fileVersion = (integer)
$version;
226 $sql = explode(
"\n",trim($str));
227 for ($i=0; $i<count($sql); $i++)
229 $sql[$i] = trim($sql[$i]);
230 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
233 if (substr($sql[$i],-1)==
";")
236 $q .=
" ".substr($sql[$i],0,-1);
245 $this->error = $e->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";
365 foreach($modules as $module)
367 $mr =
new ilModuleReader(ILIAS_ABSOLUTE_PATH.
"/Modules/".$module[
"subdir"].
"/module.xml",
368 $module[
"subdir"],
"Modules");
375 foreach($services as $service)
377 $sr =
new ilServiceReader(ILIAS_ABSOLUTE_PATH.
"/Services/".$service[
"subdir"].
"/service.xml",
378 $service[
"subdir"],
"Services");
383 $ilCtrlStructureReader->readStructure();
399 reset($this->filecontent);
401 if (!$hotfix && !$custom_update)
410 while (!preg_match(
"/^<\#".$nr.
">/", $this->filecontent[$i]) && $i<count($this->filecontent))
416 if ($i == count($this->filecontent))
418 $this->error =
"update_not_found";
426 while ($i<count($this->filecontent) && !preg_match(
"/^<#".($nr+1).
">/", $this->filecontent[$i]))
428 $update[] = trim($this->filecontent[$i]);
437 foreach ($update as
$row)
439 if (preg_match(
"/<\?php/", $row))
443 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
452 elseif (preg_match(
"/\?>/", $row))
457 if (eval(
$code) ===
false)
459 $this->error =
"Parse error: ".$code;
481 if ($mode ==
"sql" && count($sql) > 0)
483 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false)
485 $this->error =
"dump_error: ".$this->error;
491 if (!$hotfix && !$custom_update)
499 elseif($custom_update)
504 if (!$hotfix && !$custom_update)
516 if ($this->fileVersion > $this->currentVersion)
532 "name" => $status[
"Table"],
534 "status" => $status[
"Msg_text"]
544 $query =
"ANALYZE TABLE ".$table;
562 return $this->hotfix_current_version;
571 $this->hotfix_setting->set(
"db_hotfixes_".
572 $this->hotfix_version[0].
"_".$this->hotfix_version[1], $a_version);
573 $this->hotfix_current_version = $a_version;
583 return $this->hotfix_file_version;
592 reset($a_file_content);
594 foreach ($a_file_content as
$row)
596 if (preg_match(
"/^<#([0-9]+)>/", $row, $regs))
610 if ($this->hotfix_info_read && !$a_force)
614 include_once
'./Services/Administration/classes/class.ilSetting.php';
615 $this->hotfix_setting =
new ilSetting(
"common",
true);
617 $version_array = explode(
".", $ilias_version);
618 $this->hotfix_version[0] = $version_array[0];
619 $this->hotfix_version[1] = $version_array[1];
620 $hotfix_file = $this->PATH.
"setup/sql/".$this->hotfix_version[0].
"_".$this->hotfix_version[1].
"_hotfixes.php";
621 if (is_file($hotfix_file))
623 $this->hotfix_content = @
file($hotfix_file);
624 $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_".
625 $this->hotfix_version[0].
"_".$this->hotfix_version[1]);
628 $this->hotfix_info_read =
true;
637 if ($this->hotfix_file_version > $this->hotfix_current_version)
651 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
654 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
664 for ($i=($c+1); $i<=$f; $i++)
668 $this->filecontent = $this->hotfix_content;
673 "msg" =>
"update_error: ".$this->error,
676 $this->updateMsg = $msg;
682 "msg" =>
"hotfix_applied",
688 $this->updateMsg = $msg;
692 $this->updateMsg =
"no_changes";
701 return $this->custom_updates_current_version;
707 $this->custom_updates_setting->set(
'db_version_custom', $a_version);
708 $this->custom_updates_current_version = $a_version;
715 return $this->custom_updates_file_version;
721 reset($a_file_content);
723 foreach ($a_file_content as
$row)
725 if (preg_match(
"/^<#([0-9]+)>/", $row, $regs))
736 if ($this->custom_updates_info_read && !$a_force)
740 include_once
'./Services/Administration/classes/class.ilSetting.php';
742 $this->custom_updates_setting =
new ilSetting();
743 $custom_updates_file = $this->PATH.
"setup/sql/dbupdate_custom.php";
744 if (is_file($custom_updates_file))
746 $this->custom_updates_content = @
file($custom_updates_file);
747 $this->custom_updates_current_version = (int) $this->custom_updates_setting->get(
'db_version_custom', 0);
750 $this->custom_updates_info_read =
true;
759 if ($this->custom_updates_file_version > $this->custom_updates_current_version)
770 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
773 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
783 for ($i=($c+1); $i<=$f; $i++)
787 $this->filecontent = $this->custom_updates_content;
792 "msg" =>
"update_error: ".$this->error,
795 $this->updateMsg = $msg;
801 "msg" =>
"custom_update_applied",
807 $this->updateMsg = $msg;
811 $this->updateMsg =
"no_changes";
831 if ($a_break > $this->currentVersion &&
832 $a_break < $this->fileVersion)
840 for ($i=($c+1); $i<=$f; $i++)
845 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
873 for ($i=($c+1); $i<=$f; $i++)
875 $this->filecontent = $this->hotfix_content;
895 reset($this->filecontent);
901 while (!preg_match(
"/^<#".$nr.
">/", $this->filecontent[$i]) && $i<count($this->filecontent))
907 if ($i == count($this->filecontent))
916 while ($i<count($this->filecontent) && !preg_match(
"/^<#".($nr+1).
">/", $this->filecontent[$i]))
918 $str.= $this->filecontent[$i];
922 return "<pre><b><#".$nr.
"></b>\n".htmlentities($str).
"</pre>";
getFileForStep($a_version)
Get db update file name for db step.
getCustomUpdatesFileVersion()
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
const ILIAS_VERSION_NUMERIC
setRunningStatus($a_nr)
Set running status for a step.
getHotfixSteps()
Get hotfix steps.
$DB_UPDATE_FILE
db update file
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setCustomUpdatesCurrentVersion($a_version)
getHotfixFileVersion()
Get current hotfix version.
applyHotfix()
Apply hotfix.
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
Class ilDatabaseException.
readHotfixInfo($a_force=false)
Get status of hotfix file.
execQuery($db, $str)
execute a query
setHotfixCurrentVersion($a_version)
Set current hotfix version.
readCustomUpdatesFileVersion($a_file_content)
static getAvailableCoreServices()
Get all available core services.
__construct($a_db_handler=0, $tmp_flag=false)
constructor
getHotfixCurrentVersion()
Get current hotfix version.
Reload workbook from saved file
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.
readHotfixFileVersion($a_file_content)
Set current hotfix version.
checkQuery($q)
check query
Create styles array
The data for the language used.
getFileVersion()
Get Version of file.
readCustomUpdatesInfo($a_force=false)
setCurrentVersion($a_version)
getUpdateSteps($a_break=0)
Get update steps as string (for presentation)
hotfixAvailable()
Get status of hotfix file.
getRunningStatus()
Get running status.
getCustomUpdatesCurrentVersion()
clearRunningStatus()
Clear running status.
applyUpdate($a_break=0)
Apply update.
static getAvailableCoreModules()
Get all available core modules.