43 public function __construct($a_db_handler = 0, $client_ini =
null)
46 $this->client_ini = $client_ini;
48 $this->db = &$a_db_handler;
52 if (
$DIC->offsetExists(
'mySetup')) {
53 $mySetup =
$DIC[
'mySetup'];
55 $this->db = $mySetup->db;
64 $this->current_file = $updatefile;
65 $this->DB_UPDATE_FILE = $this->
PATH .
"setup/sql/" . $updatefile;
70 $this->LAST_UPDATE_FILE = $this->
PATH .
"setup/sql/dbupdate_04.php";
91 case ((
int) $a_version > 4182):
92 return "dbupdate_04.php";
93 case ((
int) $a_version > 2948):
94 return "dbupdate_03.php";
95 case ((
int) $a_version > 864):
96 return "dbupdate_02.php";
98 return "dbupdate.php";
114 if (!file_exists($this->DB_UPDATE_FILE)) {
115 $this->
error =
"no_db_update_file";
116 $this->filecontent = array();
121 $this->filecontent = @file($this->DB_UPDATE_FILE);
129 if (!file_exists($this->LAST_UPDATE_FILE)) {
130 $this->
error =
"no_last_update_file";
131 $this->lastfilecontent = array();
136 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
147 include_once
'./Services/Administration/classes/class.ilSetting.php';
149 $this->currentVersion = (integer) $set->get(
"db_version");
162 include_once
'./Services/Administration/classes/class.ilSetting.php';
164 $set->set(
"db_version", $a_version);
165 $this->currentVersion = $a_version;
178 include_once
'./Services/Administration/classes/class.ilSetting.php';
180 $set->set(
"db_update_running", $a_nr);
181 $this->db_update_running = $a_nr;
192 include_once
'./Services/Administration/classes/class.ilSetting.php';
194 $this->db_update_running = (integer) $set->get(
"db_update_running");
196 return $this->db_update_running;
205 include_once
'./Services/Administration/classes/class.ilSetting.php';
207 $set->set(
"db_update_running", 0);
208 $this->db_update_running = 0;
215 reset($this->lastfilecontent);
217 foreach ($this->lastfilecontent as
$row) {
218 if (preg_match(
'/^<\#([0-9]+)>/',
$row, $regs)) {
223 $this->fileVersion = (integer)
$version;
248 $sql = explode(
"\n", trim($str));
249 for (
$i = 0;
$i < count($sql);
$i++) {
250 $sql[
$i] = trim($sql[
$i]);
251 if ($sql[
$i] !=
"" && substr($sql[
$i], 0, 1) !=
"#") {
253 if (substr($sql[
$i], -1) ==
";") {
255 $q .=
" " . substr($sql[
$i], 0, -1);
257 if ($check ===
true) {
263 $this->
error = $e->getMessage();
268 $this->
error = $check;
275 $q .=
" " . $sql[
$i];
280 echo
"incomplete_statement: " . $q .
"<br>";
309 if (isset(
$GLOBALS[
'ilCtrlStructureReader'])) {
311 } elseif (
$DIC->offsetExists(
'ilCtrlStructureReader')) {
314 require_once
'setup/classes/class.ilCtrlStructureReader.php';
321 if (
$DIC->offsetExists(
'ilMySQLAbstraction')) {
322 $ilMySQLAbstraction =
$DIC[
'ilMySQLAbstraction'];
325 $DIC->offsetSet(
'ilMySQLAbstraction', $ilMySQLAbstraction);
328 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
330 if ($this->client_ini) {
343 $ilMySQLAbstraction =
null;
350 if ($a_break > $this->currentVersion
351 && $a_break < $this->fileVersion
368 $msg[] = array(
"msg" =>
"update_error: " . $this->
error,
370 $this->updateMsg = $msg;
374 $msg[] = array(
"msg" =>
"update_applied",
379 $this->updateMsg = $msg;
381 $this->updateMsg =
"no_changes";
384 if ($f < $this->fileVersion) {
395 $ilMySQLAbstraction =
null;
400 require_once
"./setup/classes/class.ilModuleReader.php";
401 require_once
"./setup/classes/class.ilServiceReader.php";
402 require_once
"./setup/classes/class.ilCtrlStructureReader.php";
404 require_once
"./Services/Component/classes/class.ilModule.php";
405 require_once
"./Services/Component/classes/class.ilService.php";
413 foreach ($modules as
$module) {
415 ILIAS_ABSOLUTE_PATH .
"/Modules/" .
$module[
"subdir"] .
"/module.xml",
425 foreach ($services as $service) {
427 ILIAS_ABSOLUTE_PATH .
"/Services/" . $service[
"subdir"] .
"/service.xml",
452 $ilMySQLAbstraction =
null;
457 reset($this->filecontent);
459 if (!$hotfix && !$custom_update) {
467 while (!preg_match(
"/^<\#" . $nr .
">/", $this->filecontent[
$i]) &&
$i < count($this->filecontent)) {
472 if (
$i == count($this->filecontent)) {
473 $this->
error =
"update_not_found";
482 while (
$i < count($this->filecontent) && !preg_match(
"/^<#" . ($nr + 1) .
">/", $this->filecontent[
$i])) {
483 $update[] = trim($this->filecontent[
$i]);
492 foreach ($update as
$row) {
493 if (preg_match(
"/<\?php/",
$row)) {
494 if (count($sql) > 0) {
495 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false) {
496 $this->
error = $this->error;
503 } elseif (preg_match(
"/\?>/",
$row)) {
504 if (count($php) > 0) {
505 $code = implode(
"\n", $php);
506 if (eval(
$code) ===
false) {
515 if ($mode ==
"sql") {
519 if ($mode ==
"php") {
525 if ($mode ==
"sql" && count($sql) > 0) {
526 if ($this->
execQuery($this->db, implode(
"\n", $sql)) ==
false) {
527 $this->
error =
"dump_error: " . $this->error;
534 if (!$hotfix && !$custom_update) {
538 } elseif ($custom_update) {
542 if (!$hotfix && !$custom_update) {
554 if ($this->fileVersion > $this->currentVersion) {
570 $a[] = array(
"name" => $status[
"Table"],
572 "status" => $status[
"Msg_text"],);
602 return $this->hotfix_current_version;
612 $this->hotfix_setting->set(
613 "db_hotfixes_" . $this->hotfix_version[0] .
"_" . $this->hotfix_version[1],
616 $this->hotfix_current_version = $a_version;
629 return $this->hotfix_file_version;
639 reset($a_file_content);
641 foreach ($a_file_content as
$row) {
642 if (preg_match(
"/^<#([0-9]+)>/",
$row, $regs)) {
656 if ($this->hotfix_info_read && !$a_force) {
659 include_once
'./Services/Administration/classes/class.ilSetting.php';
660 $this->hotfix_setting =
new ilSetting(
"common",
true);
662 $version_array = explode(
".", $ilias_version);
663 $this->hotfix_version[0] = $version_array[0];
664 $this->hotfix_version[1] = $version_array[1];
665 $hotfix_file = $this->
PATH .
"setup/sql/" . $this->hotfix_version[0] .
"_" . $this->hotfix_version[1] .
"_hotfixes.php";
666 if (is_file($hotfix_file)) {
667 $this->hotfix_content = @file($hotfix_file);
668 $this->hotfix_current_version = (int) $this->hotfix_setting->get(
669 "db_hotfixes_" . $this->hotfix_version[0] .
"_" . $this->hotfix_version[1]
673 $this->hotfix_info_read =
true;
683 if ($this->hotfix_file_version > $this->hotfix_current_version) {
697 $ilMySQLAbstraction =
null;
701 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
704 $GLOBALS[
'DIC'][
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
716 $this->filecontent = $this->hotfix_content;
719 $msg[] = array(
"msg" =>
"update_error: " . $this->
error,
721 $this->updateMsg = $msg;
725 $msg[] = array(
"msg" =>
"hotfix_applied",
730 $this->updateMsg = $msg;
732 $this->updateMsg =
"no_changes";
743 return $this->custom_updates_current_version;
750 $this->custom_updates_setting->set(
'db_version_custom', $a_version);
751 $this->custom_updates_current_version = $a_version;
761 return $this->custom_updates_file_version;
768 reset($a_file_content);
770 foreach ($a_file_content as
$row) {
771 if (preg_match(
"/^<#([0-9]+)>/",
$row, $regs)) {
782 if ($this->custom_updates_info_read && !$a_force) {
785 include_once
'./Services/Administration/classes/class.ilSetting.php';
787 $this->custom_updates_setting =
new ilSetting();
788 $custom_updates_file = $this->
PATH .
"setup/sql/dbupdate_custom.php";
789 if (is_file($custom_updates_file)) {
790 $this->custom_updates_content = @file($custom_updates_file);
791 $this->custom_updates_current_version = (int) $this->custom_updates_setting->get(
'db_version_custom', 0);
794 $this->custom_updates_info_read =
true;
804 if ($this->custom_updates_file_version > $this->custom_updates_current_version) {
815 $ilMySQLAbstraction =
null;
819 include_once
'./Services/Database/classes/class.ilMySQLAbstraction.php';
822 $GLOBALS[
'DIC'][
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
832 $this->filecontent = $this->custom_updates_content;
835 $msg[] = array(
"msg" =>
"update_error: " . $this->
error,
837 $this->updateMsg = $msg;
841 $msg[] = array(
"msg" =>
"custom_update_applied",
846 $this->updateMsg = $msg;
848 $this->updateMsg =
"no_changes";
863 $ilMySQLAbstraction =
null;
872 if ($a_break > $this->currentVersion
873 && $a_break < $this->fileVersion
912 $this->filecontent = $this->hotfix_content;
930 reset($this->filecontent);
936 while (!preg_match(
"/^<#" . $nr .
">/", $this->filecontent[
$i]) &&
$i < count($this->filecontent)) {
941 if (
$i == count($this->filecontent)) {
949 while (
$i < count($this->filecontent) && !preg_match(
"/^<#" . ($nr + 1) .
">/", $this->filecontent[
$i])) {
950 $str .= $this->filecontent[
$i];
954 return "<pre><b><#" . $nr .
"></b>\n" . htmlentities($str) .
"</pre>";
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
Class ilCtrlStructureReader.
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.
getFileVersion()
Get Version of file.
applyUpdate($a_break=0)
Apply update.
readCustomUpdatesInfo($a_force=false)
__construct($a_db_handler=0, $client_ini=null)
ilDBUpdate constructor.
$DB_UPDATE_FILE
db update file
getHotfixSteps()
Get hotfix steps.
setCurrentVersion($a_version)
getFileForStep($a_version)
Get db update file name for db step.
getCustomUpdatesFileVersion()
getUpdateSteps($a_break=0)
Get update steps as string (for presentation)
setRunningStatus($a_nr)
Set running status for a step.
getCustomUpdatesCurrentVersion()
setHotfixCurrentVersion($a_version)
Set current hotfix version.
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
execQuery($db, $str)
execute a query
checkQuery($q)
check query
getHotfixCurrentVersion()
Get current hotfix version.
getHotfixFileVersion()
Get current hotfix version.
readHotfixInfo($a_force=false)
Get status of hotfix file.
readCustomUpdatesFileVersion($a_file_content)
hotfixAvailable()
Get status of hotfix file.
setCustomUpdatesCurrentVersion($a_version)
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
clearRunningStatus()
Clear running status.
applyHotfix()
Apply hotfix.
getRunningStatus()
Get running status.
readHotfixFileVersion($a_file_content)
Set current hotfix version.
Class ilDatabaseException.
static getAvailableCoreModules()
Get all available core modules.
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
static getAvailableCoreServices()
Get all available core services.
const ILIAS_VERSION_NUMERIC
if($modEnd===false) $module
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
if(empty($password)) $table
foreach($_POST as $key=> $value) $res