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_05.php";
 
   91            case ((
int) $a_version > 5431): 
 
   92                return "dbupdate_05.php";
 
   93            case ((
int) $a_version > 4182): 
 
   94                return "dbupdate_04.php";
 
   95            case ((
int) $a_version > 2948): 
 
   96                return "dbupdate_03.php";
 
   97            case ((
int) $a_version > 864): 
 
   98                return "dbupdate_02.php";
 
  100                return "dbupdate.php";
 
  116        if (!file_exists($this->DB_UPDATE_FILE)) {
 
  117            $this->
error = 
"no_db_update_file";
 
  118            $this->filecontent = array();
 
  123        $this->filecontent = @file($this->DB_UPDATE_FILE);
 
  131        if (!file_exists($this->LAST_UPDATE_FILE)) {
 
  132            $this->
error = 
"no_last_update_file";
 
  133            $this->lastfilecontent = array();
 
  138        $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
 
  150        $this->currentVersion = (integer) $set->get(
"db_version");
 
  164        $set->set(
"db_version", $a_version);
 
  165        $this->currentVersion = $a_version;
 
  179        $set->set(
"db_update_running", $a_nr);
 
  180        $this->db_update_running = $a_nr;
 
  192        $this->db_update_running = (integer) $set->get(
"db_update_running");
 
  194        return $this->db_update_running;
 
  204        $set->set(
"db_update_running", 0);
 
  205        $this->db_update_running = 0;
 
  212        reset($this->lastfilecontent);
 
  214        foreach ($this->lastfilecontent as $row) {
 
  215            if (preg_match(
'/^<\#([0-9]+)>/', $row, $regs)) {
 
  220        $this->fileVersion = (integer) $version;
 
  245        $sql = explode(
"\n", trim($str));
 
  246        for (
$i = 0; 
$i < count($sql); 
$i++) {
 
  247            $sql[
$i] = trim($sql[
$i]);
 
  248            if ($sql[
$i] != 
"" && substr($sql[
$i], 0, 1) != 
"#") {
 
  250                if (substr($sql[
$i], -1) == 
";") {
 
  252                    $q .= 
" " . substr($sql[
$i], 0, -1);
 
  254                    if ($check === 
true) {
 
  260                            $this->
error = $e->getMessage();
 
  265                        $this->
error = $check;
 
  272                    $q .= 
" " . $sql[
$i];
 
  276        if (isset($q) && $q != 
"") {
 
  277            echo 
"incomplete_statement: " . $q . 
"<br>";
 
  306        if (isset(
$GLOBALS[
'ilCtrlStructureReader'])) {
 
  308        } elseif (
$DIC->offsetExists(
'ilCtrlStructureReader')) {
 
  317        if (
$DIC->offsetExists(
'ilMySQLAbstraction')) {
 
  318            $ilMySQLAbstraction = 
$DIC[
'ilMySQLAbstraction'];
 
  321            $DIC->offsetSet(
'ilMySQLAbstraction', $ilMySQLAbstraction);
 
  324        $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  326        if ($this->client_ini) {
 
  339        $ilMySQLAbstraction = 
null;
 
  346        if ($a_break > $this->currentVersion
 
  347            && $a_break < $this->fileVersion
 
  364                    $msg[] = array(
"msg" => 
"update_error: " . $this->
error,
 
  366                    $this->updateMsg = $msg;
 
  370                    $msg[] = array(
"msg" => 
"update_applied",
 
  375            $this->updateMsg = $msg;
 
  377            $this->updateMsg = 
"no_changes";
 
  380        if ($f < $this->fileVersion) {
 
  391        $ilMySQLAbstraction = 
null;
 
  403        foreach ($modules as $module) {
 
  405                ILIAS_ABSOLUTE_PATH . 
"/Modules/" . $module[
"subdir"] . 
"/module.xml",
 
  417                ILIAS_ABSOLUTE_PATH . 
"/Services/" . 
$service[
"subdir"] . 
"/service.xml",
 
  439    public function applyUpdateNr(&$nr, $hotfix = 
false, $custom_update = 
false)
 
  442        $ilMySQLAbstraction = 
null;
 
  447        reset($this->filecontent);
 
  449        if (!$hotfix && !$custom_update) {
 
  457        while (!preg_match(
"/^<\#" . $nr . 
">/", $this->filecontent[
$i]) && 
$i < count($this->filecontent)) {
 
  462        if (
$i == count($this->filecontent)) {
 
  463            $this->
error = 
"update_not_found";
 
  472        while (
$i < count($this->filecontent) && !preg_match(
"/^<#" . ($nr + 1) . 
">/", $this->filecontent[
$i])) {
 
  473            $update[] = trim($this->filecontent[
$i]);
 
  482        foreach ($update as $row) {
 
  483            if (preg_match(
"/<\?php/", $row)) {
 
  484                if (count($sql) > 0) {
 
  485                    if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false) {
 
  486                        $this->
error = $this->error;
 
  493            } elseif (preg_match(
"/\?>/", $row)) {
 
  494                if (count($php) > 0) {
 
  495                    $code = implode(
"\n", $php);
 
  496                    if (eval($code) === 
false) {
 
  497                        $this->
error = 
"Parse error: " . $code;
 
  505                if ($mode == 
"sql") {
 
  509                if ($mode == 
"php") {
 
  515        if ($mode == 
"sql" && count($sql) > 0) {
 
  516            if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false) {
 
  517                $this->
error = 
"dump_error: " . $this->error;
 
  524        if (!$hotfix && !$custom_update) {
 
  528        } elseif ($custom_update) {
 
  532        if (!$hotfix && !$custom_update) {
 
  544        if ($this->fileVersion > $this->currentVersion) {
 
  558        while ($row = 
$res->fetchRow()) {
 
  560            $a[] = array(
"name" => $status[
"Table"],
 
  562                         "status" => $status[
"Msg_text"],);
 
  573        $query = 
"ANALYZE TABLE " . $table;
 
  592        return $this->hotfix_current_version ?? 
null;
 
  602        $this->hotfix_setting->set(
 
  603            "db_hotfixes_" . $this->hotfix_version[0],
 
  606        $this->hotfix_current_version = $a_version;
 
  619        return $this->hotfix_file_version ?? 
null;
 
  629        reset($a_file_content);
 
  631        foreach ($a_file_content as $row) {
 
  632            if (preg_match(
"/^<#([0-9]+)>/", $row, $regs)) {
 
  637        return (integer) $version;
 
  646        if (isset($this->hotfix_info_read) && $this->hotfix_info_read && !$a_force) {
 
  649        $this->hotfix_setting = 
new ilSetting(
"common", 
true);
 
  651        $version_array = explode(
".", $ilias_version);
 
  652        $this->hotfix_version[0] = $version_array[0];
 
  653        $this->hotfix_version[1] = $version_array[1];
 
  654        $hotfix_file = $this->
PATH . 
"setup/sql/" . $this->hotfix_version[0] . 
"_hotfixes.php";
 
  655        if (is_file($hotfix_file)) {
 
  656            $this->hotfix_content = @file($hotfix_file);
 
  657            $this->hotfix_current_version = (int) $this->hotfix_setting->get(
 
  658                "db_hotfixes_" . $this->hotfix_version[0]
 
  662        $this->hotfix_info_read = 
true;
 
  672        if (isset($this->hotfix_file_version) && $this->hotfix_file_version > $this->hotfix_current_version) {
 
  686        $ilMySQLAbstraction = 
null;
 
  691        $GLOBALS[
'DIC'][
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  703                $this->filecontent = $this->hotfix_content;
 
  706                    $msg[] = array(
"msg" => 
"update_error: " . $this->
error,
 
  708                    $this->updateMsg = $msg;
 
  712                    $msg[] = array(
"msg" => 
"hotfix_applied",
 
  717            $this->updateMsg = $msg;
 
  719            $this->updateMsg = 
"no_changes";
 
  730        return $this->custom_updates_current_version;
 
  737        $this->custom_updates_setting->set(
'db_version_custom', $a_version);
 
  738        $this->custom_updates_current_version = $a_version;
 
  748        return $this->custom_updates_file_version;
 
  755        reset($a_file_content);
 
  757        foreach ($a_file_content as $row) {
 
  758            if (preg_match(
"/^<#([0-9]+)>/", $row, $regs)) {
 
  763        return (integer) $version;
 
  769        if ($this->custom_updates_info_read && !$a_force) {
 
  773        $this->custom_updates_setting = 
new ilSetting();
 
  774        $custom_updates_file = $this->
PATH . 
"setup/sql/dbupdate_custom.php";
 
  775        if (is_file($custom_updates_file)) {
 
  776            $this->custom_updates_content = @file($custom_updates_file);
 
  777            $this->custom_updates_current_version = (int) $this->custom_updates_setting->get(
'db_version_custom', 0);
 
  780        $this->custom_updates_info_read = 
true;
 
  790        if ($this->custom_updates_file_version > $this->custom_updates_current_version) {
 
  801        $ilMySQLAbstraction = 
null;
 
  806        $GLOBALS[
'DIC'][
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  816                $this->filecontent = $this->custom_updates_content;
 
  819                    $msg[] = array(
"msg" => 
"update_error: " . $this->
error,
 
  821                    $this->updateMsg = $msg;
 
  825                    $msg[] = array(
"msg" => 
"custom_update_applied",
 
  830            $this->updateMsg = $msg;
 
  832            $this->updateMsg = 
"no_changes";
 
  847        $ilMySQLAbstraction = 
null;
 
  856        if ($a_break > $this->currentVersion
 
  857            && $a_break < $this->fileVersion
 
  896                $this->filecontent = $this->hotfix_content;
 
  914        reset($this->filecontent);
 
  920        while (!preg_match(
"/^<#" . $nr . 
">/", $this->filecontent[
$i]) && 
$i < count($this->filecontent)) {
 
  925        if (
$i == count($this->filecontent)) {
 
  933        while (
$i < count($this->filecontent) && !preg_match(
"/^<#" . ($nr + 1) . 
">/", $this->filecontent[
$i])) {
 
  934            $str .= $this->filecontent[
$i];
 
  938        return "<pre><b><#" . $nr . 
"></b>\n" . htmlentities($str) . 
"</pre>";
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res