34    public function __construct($a_db_handler = 0, $tmp_flag = 
false)
 
   38            $this->db =&$a_db_handler;
 
   48            $this->db = $mySetup->db;
 
   57        $this->current_file = $updatefile;
 
   58        $this->DB_UPDATE_FILE = $this->
PATH . 
"setup/sql/" . $updatefile;
 
   63        $this->LAST_UPDATE_FILE = $this->
PATH . 
"setup/sql/dbupdate_04.php";
 
   78        if ((
int) $a_version > 4182) {          
 
   79            return "dbupdate_04.php";
 
   80        } elseif ((
int) $a_version > 2948) {            
 
   81            return "dbupdate_03.php";
 
   82        } elseif ((
int) $a_version > 864) {             
 
   83            return "dbupdate_02.php";
 
   85            return "dbupdate.php";
 
  100        if (!file_exists($this->DB_UPDATE_FILE)) {
 
  101            $this->
error = 
"no_db_update_file";
 
  102            $this->filecontent = array();
 
  106        $this->filecontent = @file($this->DB_UPDATE_FILE);
 
  112        if (!file_exists($this->LAST_UPDATE_FILE)) {
 
  113            $this->
error = 
"no_last_update_file";
 
  114            $this->lastfilecontent = array();
 
  118        $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
 
  124        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  126        $this->currentVersion = (integer) $set->get(
"db_version");
 
  132        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  134        $set->set(
"db_version", $a_version);
 
  135        $this->currentVersion = $a_version;
 
  147        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  149        $set->set(
"db_update_running", $a_nr);
 
  150        $this->db_update_running = $a_nr;
 
  160        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  162        $this->db_update_running = (integer) $set->get(
"db_update_running");
 
  164        return $this->db_update_running;
 
  172        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  174        $set->set(
"db_update_running", 0);
 
  175        $this->db_update_running = 0;
 
  181        reset($this->lastfilecontent);
 
  183        foreach ($this->lastfilecontent as 
$row) {
 
  184            if (preg_match(
'/^<\#([0-9]+)>/', 
$row, $regs)) {
 
  189        $this->fileVersion = (integer) 
$version;
 
  209        $sql = explode(
"\n", trim($str));
 
  210        for (
$i=0; 
$i<count($sql); 
$i++) {
 
  211            $sql[
$i] = trim($sql[
$i]);
 
  212            if ($sql[
$i] != 
"" && substr($sql[
$i], 0, 1)!=
"#") {
 
  214                if (substr($sql[
$i], -1)==
";") {
 
  216                    $q .= 
" " . substr($sql[
$i], 0, -1);
 
  218                    if ($check === 
true) {
 
  224                            $this->
error = $e->getMessage();
 
  229                        $this->
error = $check;
 
  235                    $q .= 
" " . $sql[
$i];
 
  240            echo 
"incomplete_statement: " . $q . 
"<br>";
 
  261        include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  264        $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  269        if ($a_break > $this->currentVersion &&
 
  270            $a_break < $this->fileVersion) {
 
  276            for (
$i=($c+1); 
$i<=$f; 
$i++) {
 
  287                        "msg" => 
"update_error: " . $this->
error,
 
  290                    $this->updateMsg = $msg;
 
  294                        "msg" => 
"update_applied",
 
  300            $this->updateMsg = $msg;
 
  302            $this->updateMsg = 
"no_changes";
 
  305        if ($f < $this->fileVersion) {
 
  317        require_once 
"./setup/classes/class.ilModuleReader.php";
 
  318        require_once 
"./setup/classes/class.ilServiceReader.php";
 
  319        require_once 
"./setup/classes/class.ilCtrlStructureReader.php";
 
  321        require_once 
"./Services/Component/classes/class.ilModule.php";
 
  322        require_once 
"./Services/Component/classes/class.ilService.php";
 
  328        foreach ($modules as 
$module) {
 
  330                ILIAS_ABSOLUTE_PATH . 
"/Modules/" . 
$module[
"subdir"] . 
"/module.xml",
 
  342                ILIAS_ABSOLUTE_PATH . 
"/Services/" . 
$service[
"subdir"] . 
"/service.xml",
 
  366        reset($this->filecontent);
 
  368        if (!$hotfix && !$custom_update) {
 
  376        while (!preg_match(
"/^<\#" . $nr . 
">/", $this->filecontent[
$i]) && 
$i<count($this->filecontent)) {
 
  381        if (
$i == count($this->filecontent)) {
 
  382            $this->
error = 
"update_not_found";
 
  390        while (
$i<count($this->filecontent) && !preg_match(
"/^<#" . ($nr+1) . 
">/", $this->filecontent[
$i])) {
 
  391            $update[] = trim($this->filecontent[
$i]);
 
  400        foreach ($update as 
$row) {
 
  401            if (preg_match(
"/<\?php/", 
$row)) {
 
  403                    if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false) {
 
  410            } elseif (preg_match(
"/\?>/", 
$row)) {
 
  413                    if (eval(
$code) === 
false) {
 
  421                if ($mode == 
"sql") {
 
  425                if ($mode == 
"php") {
 
  431        if ($mode == 
"sql" && count($sql) > 0) {
 
  432            if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false) {
 
  439        if (!$hotfix && !$custom_update) {
 
  443        } elseif ($custom_update) {
 
  447        if (!$hotfix && !$custom_update) {
 
  457        if ($this->fileVersion > $this->currentVersion) {
 
  473                "name" => $status[
"Table"],
 
  475                "status" => $status[
"Msg_text"]
 
  503        return $this->hotfix_current_version;
 
  512        $this->hotfix_setting->set(
"db_hotfixes_" .
 
  513            $this->hotfix_version[0] . 
"_" . $this->hotfix_version[1], $a_version);
 
  514        $this->hotfix_current_version = $a_version;
 
  524        return $this->hotfix_file_version;
 
  533        reset($a_file_content);
 
  535        foreach ($a_file_content as 
$row) {
 
  536            if (preg_match(
"/^<#([0-9]+)>/", 
$row, $regs)) {
 
  549        if ($this->hotfix_info_read && !$a_force) {
 
  552        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  553        $this->hotfix_setting = 
new ilSetting(
"common", 
true);
 
  555        $version_array = explode(
".", $ilias_version);
 
  556        $this->hotfix_version[0] = $version_array[0];
 
  557        $this->hotfix_version[1] = $version_array[1];
 
  558        $hotfix_file = $this->
PATH . 
"setup/sql/" . $this->hotfix_version[0] . 
"_" . $this->hotfix_version[1] . 
"_hotfixes.php";
 
  559        if (is_file($hotfix_file)) {
 
  560            $this->hotfix_content = @file($hotfix_file);
 
  561            $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_" .
 
  562                $this->hotfix_version[0] . 
"_" . $this->hotfix_version[1]);
 
  565        $this->hotfix_info_read = 
true;
 
  574        if ($this->hotfix_file_version > $this->hotfix_current_version) {
 
  587        include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  590        $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  599            for (
$i=($c+1); 
$i<=$f; 
$i++) {
 
  602                $this->filecontent = $this->hotfix_content;
 
  606                        "msg" => 
"update_error: " . $this->
error,
 
  609                    $this->updateMsg = $msg;
 
  613                        "msg" => 
"hotfix_applied",
 
  619            $this->updateMsg = $msg;
 
  621            $this->updateMsg = 
"no_changes";
 
  630        return $this->custom_updates_current_version;
 
  636        $this->custom_updates_setting->set(
'db_version_custom', $a_version);
 
  637        $this->custom_updates_current_version = $a_version;
 
  644        return $this->custom_updates_file_version;
 
  650        reset($a_file_content);
 
  652        foreach ($a_file_content as 
$row) {
 
  653            if (preg_match(
"/^<#([0-9]+)>/", 
$row, $regs)) {
 
  663        if ($this->custom_updates_info_read && !$a_force) {
 
  666        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  668        $this->custom_updates_setting = 
new ilSetting();
 
  669        $custom_updates_file = $this->
PATH . 
"setup/sql/dbupdate_custom.php";
 
  670        if (is_file($custom_updates_file)) {
 
  671            $this->custom_updates_content = @file($custom_updates_file);
 
  672            $this->custom_updates_current_version = (int) $this->custom_updates_setting->get(
'db_version_custom', 0);
 
  675        $this->custom_updates_info_read = 
true;
 
  684        if ($this->custom_updates_file_version > $this->custom_updates_current_version) {
 
  694        include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  697        $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  706            for (
$i=($c+1); 
$i<=$f; 
$i++) {
 
  709                $this->filecontent = $this->custom_updates_content;
 
  713                        "msg" => 
"update_error: " . $this->
error,
 
  716                    $this->updateMsg = $msg;
 
  720                        "msg" => 
"custom_update_applied",
 
  726            $this->updateMsg = $msg;
 
  728            $this->updateMsg = 
"no_changes";
 
  748        if ($a_break > $this->currentVersion &&
 
  749            $a_break < $this->fileVersion) {
 
  755            for (
$i=($c+1); 
$i<=$f; 
$i++) {
 
  784            for (
$i=($c+1); 
$i<=$f; 
$i++) {
 
  785                $this->filecontent = $this->hotfix_content;
 
  805        reset($this->filecontent);
 
  811        while (!preg_match(
"/^<#" . $nr . 
">/", $this->filecontent[
$i]) && 
$i<count($this->filecontent)) {
 
  816        if (
$i == count($this->filecontent)) {
 
  824        while (
$i<count($this->filecontent) && !preg_match(
"/^<#" . ($nr+1) . 
">/", $this->filecontent[
$i])) {
 
  825            $str.= $this->filecontent[
$i];
 
  829        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
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)
$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.
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.
__construct($a_db_handler=0, $tmp_flag=false)
constructor
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const ILIAS_VERSION_NUMERIC
if($modEnd===false) $module
if(empty($password)) $table
foreach($_POST as $key=> $value) $res