ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDBUpdate Class Reference

Database Update class. More...

+ Inheritance diagram for ilDBUpdate:
+ Collaboration diagram for ilDBUpdate:

Public Member Functions

 __construct ($a_db_handler=0, $client_ini=null)
 ilDBUpdate constructor. More...
 
 getFileForStep ($a_version)
 Get db update file name for db step. More...
 
 initStep ($i)
 
 readDBUpdateFile ()
 
 readLastUpdateFile ()
 
 getCurrentVersion ()
 
 setCurrentVersion ($a_version)
 
 setRunningStatus ($a_nr)
 Set running status for a step. More...
 
 getRunningStatus ()
 Get running status. More...
 
 clearRunningStatus ()
 Clear running status. More...
 
 readFileVersion ()
 
 getFileVersion ()
 Get Version of file. More...
 
 execQuery ($db, $str)
 execute a query More...
 
 checkQuery ($q)
 check query More...
 
 applyUpdate ($a_break=0)
 Apply update. More...
 
 loadXMLInfo ()
 
 applyUpdateNr ($nr, $hotfix=false, $custom_update=false)
 apply an update More...
 
 getDBVersionStatus ()
 
 getTables ()
 
 getTableStatus ($table)
 
 getHotfixCurrentVersion ()
 Get current hotfix version. More...
 
 setHotfixCurrentVersion ($a_version)
 Set current hotfix version. More...
 
 getHotfixFileVersion ()
 Get current hotfix version. More...
 
 readHotfixFileVersion ($a_file_content)
 Set current hotfix version. More...
 
 readHotfixInfo ($a_force=false)
 Get status of hotfix file. More...
 
 hotfixAvailable ()
 Get status of hotfix file. More...
 
 applyHotfix ()
 Apply hotfix. More...
 
 getCustomUpdatesCurrentVersion ()
 
 setCustomUpdatesCurrentVersion ($a_version)
 
 getCustomUpdatesFileVersion ()
 
 readCustomUpdatesFileVersion ($a_file_content)
 
 readCustomUpdatesInfo ($a_force=false)
 
 customUpdatesAvailable ()
 
 applyCustomUpdates ()
 
 getUpdateSteps ($a_break=0)
 Get update steps as string (for presentation) More...
 
 getHotfixSteps ()
 Get hotfix steps. More...
 
 getUpdateStepNr ($nr, $hotfix=false, $custom_update=false)
 Get single update step for presentation. More...
 

Data Fields

 $DB_UPDATE_FILE
 db update file More...
 
 $currentVersion
 
 $fileVersion
 
 $updateMsg
 

Private Member Functions

 initGlobalsRequiredForUpdateSteps (&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
 

Detailed Description

Database Update class.

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilDBUpdate.php.

Constructor & Destructor Documentation

◆ __construct()

ilDBUpdate::__construct (   $a_db_handler = 0,
  $client_ini = null 
)

ilDBUpdate constructor.

Parameters
ilDBInterface$a_db_handler
bool$tmp_flag

Definition at line 43 of file class.ilDBUpdate.php.

44 {
45 // workaround to allow setup migration
46 $this->client_ini = $client_ini;
47 if ($a_db_handler) {
48 $this->db = &$a_db_handler;
49 $this->PATH = "./";
50 } else {
51 global $DIC;
52 if ($DIC->offsetExists('mySetup')) {
53 $mySetup = $DIC['mySetup'];
54 }
55 $this->db = $mySetup->db;
56 $this->PATH = "./";
57 }
58
59 $this->getCurrentVersion();
60
61 // get update file for current version
62 $updatefile = $this->getFileForStep($this->currentVersion + 1);
63
64 $this->current_file = $updatefile;
65 $this->DB_UPDATE_FILE = $this->PATH . "setup/sql/" . $updatefile;
66
67 //
68 // NOTE: IF YOU SET THIS TO THE NEWEST FILE, CHANGE ALSO getFileForStep()
69 //
70 $this->LAST_UPDATE_FILE = $this->PATH . "setup/sql/dbupdate_04.php";
71
72 $this->readDBUpdateFile();
73 $this->readLastUpdateFile();
74 $this->readFileVersion();
75 }
getFileForStep($a_version)
Get db update file name for db step.
const PATH
Definition: proxy_ylocal.php:8
global $DIC
Definition: saml.php:7

References $DIC, getCurrentVersion(), getFileForStep(), PATH, readDBUpdateFile(), readFileVersion(), and readLastUpdateFile().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyCustomUpdates()

ilDBUpdate::applyCustomUpdates ( )

Definition at line 812 of file class.ilDBUpdate.php.

813 {
815 $ilMySQLAbstraction = null;
816 $ilDB = null;
818
819 include_once './Services/Database/classes/class.ilMySQLAbstraction.php';
820
821 $ilMySQLAbstraction = new ilMySQLAbstraction();
822 $GLOBALS['DIC']['ilMySQLAbstraction'] = $ilMySQLAbstraction;
823
824 $this->readCustomUpdatesInfo(true);
825
828
829 if ($c < $f) {
830 $msg = array();
831 for ($i = ($c + 1); $i <= $f; $i++) {
832 $this->filecontent = $this->custom_updates_content;
833
834 if ($this->applyUpdateNr($i, false, true) == false) {
835 $msg[] = array("msg" => "update_error: " . $this->error,
836 "nr" => $i,);
837 $this->updateMsg = $msg;
838
839 return false;
840 } else {
841 $msg[] = array("msg" => "custom_update_applied",
842 "nr" => $i,);
843 }
844 }
845
846 $this->updateMsg = $msg;
847 } else {
848 $this->updateMsg = "no_changes";
849 }
850
851 return $this->loadXMLInfo();
852 }
error($a_errmsg)
set error message @access public
readCustomUpdatesInfo($a_force=false)
getCustomUpdatesCurrentVersion()
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$i
Definition: disco.tpl.php:19
$ilCtrlStructureReader
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
global $ilDB

References $c, $f, $GLOBALS, $i, $ilCtrlStructureReader, $ilDB, applyUpdateNr(), error(), getCustomUpdatesCurrentVersion(), getCustomUpdatesFileVersion(), initGlobalsRequiredForUpdateSteps(), loadXMLInfo(), and readCustomUpdatesInfo().

+ Here is the call graph for this function:

◆ applyHotfix()

ilDBUpdate::applyHotfix ( )

Apply hotfix.

Definition at line 694 of file class.ilDBUpdate.php.

695 {
697 $ilMySQLAbstraction = null;
698 $ilDB = null;
700
701 include_once './Services/Database/classes/class.ilMySQLAbstraction.php';
702
703 $ilMySQLAbstraction = new ilMySQLAbstraction();
704 $GLOBALS['DIC']['ilMySQLAbstraction'] = $ilMySQLAbstraction;
705
706 $this->readHotfixInfo(true);
707
708 $f = $this->getHotfixFileVersion();
709 $c = $this->getHotfixCurrentVersion();
710
711 if ($c < $f) {
712 $msg = array();
713 for ($i = ($c + 1); $i <= $f; $i++) {
714 // $this->initStep($i); // nothings happens here
715
716 $this->filecontent = $this->hotfix_content;
717
718 if ($this->applyUpdateNr($i, true) == false) {
719 $msg[] = array("msg" => "update_error: " . $this->error,
720 "nr" => $i,);
721 $this->updateMsg = $msg;
722
723 return false;
724 } else {
725 $msg[] = array("msg" => "hotfix_applied",
726 "nr" => $i,);
727 }
728 }
729
730 $this->updateMsg = $msg;
731 } else {
732 $this->updateMsg = "no_changes";
733 }
734
735 return $this->loadXMLInfo();
736 }
getHotfixCurrentVersion()
Get current hotfix version.
getHotfixFileVersion()
Get current hotfix version.
readHotfixInfo($a_force=false)
Get status of hotfix file.

References $c, $f, $GLOBALS, $i, $ilCtrlStructureReader, $ilDB, applyUpdateNr(), error(), getHotfixCurrentVersion(), getHotfixFileVersion(), initGlobalsRequiredForUpdateSteps(), loadXMLInfo(), and readHotfixInfo().

+ Here is the call graph for this function:

◆ applyUpdate()

ilDBUpdate::applyUpdate (   $a_break = 0)

Apply update.

Definition at line 340 of file class.ilDBUpdate.php.

341 {
343 $ilMySQLAbstraction = null;
344 $ilDB = null;
346
349
350 if ($a_break > $this->currentVersion
351 && $a_break < $this->fileVersion
352 ) {
353 $f = $a_break;
354 }
355
356 if ($c < $f) {
357 $msg = array();
358 for ($i = ($c + 1); $i <= $f; $i++) {
359 // check wether next update file must be loaded
360 if ($this->current_file != $this->getFileForStep($i)) {
361 $this->DB_UPDATE_FILE = $this->PATH . "setup/sql/" . $this->getFileForStep($i);
362 $this->readDBUpdateFile();
363 }
364
365 $this->initStep($i);
366
367 if ($this->applyUpdateNr($i, $inifile) == false) {
368 $msg[] = array("msg" => "update_error: " . $this->error,
369 "nr" => $i,);
370 $this->updateMsg = $msg;
371
372 return false;
373 } else {
374 $msg[] = array("msg" => "update_applied",
375 "nr" => $i,);
376 }
377 }
378
379 $this->updateMsg = $msg;
380 } else {
381 $this->updateMsg = "no_changes";
382 }
383
384 if ($f < $this->fileVersion) {
385 return true;
386 } else {
387 return $this->loadXMLInfo();
388 }
389 }

References $c, $currentVersion, $f, $fileVersion, $i, $ilCtrlStructureReader, $ilDB, applyUpdateNr(), error(), getFileForStep(), initGlobalsRequiredForUpdateSteps(), initStep(), loadXMLInfo(), PATH, and readDBUpdateFile().

+ Here is the call graph for this function:

◆ applyUpdateNr()

ilDBUpdate::applyUpdateNr (   $nr,
  $hotfix = false,
  $custom_update = false 
)

apply an update

Parameters
intnr number what patch to apply
Returns
bool @access private

Definition at line 449 of file class.ilDBUpdate.php.

450 {
452 $ilMySQLAbstraction = null;
453 $ilDB = null;
455
456 //search for desired $nr
457 reset($this->filecontent);
458
459 if (!$hotfix && !$custom_update) {
460 $this->setRunningStatus($nr);
461 }
462
463 //init
464 $i = 0;
465
466 //go through filecontent
467 while (!preg_match("/^<\#" . $nr . ">/", $this->filecontent[$i]) && $i < count($this->filecontent)) {
468 $i++;
469 }
470
471 //update not found
472 if ($i == count($this->filecontent)) {
473 $this->error = "update_not_found";
474
475 return false;
476 }
477
478 $i++;
479
480 //update found, now extract this update to a new array
481 $update = array();
482 while ($i < count($this->filecontent) && !preg_match("/^<#" . ($nr + 1) . ">/", $this->filecontent[$i])) {
483 $update[] = trim($this->filecontent[$i]);
484 $i++;
485 }
486
487 //now you have the update, now process it
488 $sql = array();
489 $php = array();
490 $mode = "sql";
491
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;
497
498 return false;
499 }
500 $sql = array();
501 }
502 $mode = "php";
503 } elseif (preg_match("/\?>/", $row)) {
504 if (count($php) > 0) {
505 $code = implode("\n", $php);
506 if (eval($code) === false) {
507 $this->error = "Parse error: " . $code;
508
509 return false;
510 }
511 $php = array();
512 }
513 $mode = "sql";
514 } else {
515 if ($mode == "sql") {
516 $sql[] = $row;
517 }
518
519 if ($mode == "php") {
520 $php[] = $row;
521 }
522 } //else
523 } //foreach
524
525 if ($mode == "sql" && count($sql) > 0) {
526 if ($this->execQuery($this->db, implode("\n", $sql)) == false) {
527 $this->error = "dump_error: " . $this->error;
528
529 return false;
530 }
531 }
532
533 //increase db_Version number
534 if (!$hotfix && !$custom_update) {
535 $this->setCurrentVersion($nr);
536 } elseif ($hotfix) {
537 $this->setHotfixCurrentVersion($nr);
538 } elseif ($custom_update) {
540 }
541
542 if (!$hotfix && !$custom_update) {
543 $this->clearRunningStatus();
544 }
545
546 //$this->currentVersion = $ilias->getSetting("db_version");
547
548 return true;
549 }
setCurrentVersion($a_version)
setRunningStatus($a_nr)
Set running status for a step.
setHotfixCurrentVersion($a_version)
Set current hotfix version.
execQuery($db, $str)
execute a query
setCustomUpdatesCurrentVersion($a_version)
clearRunningStatus()
Clear running status.
$code
Definition: example_050.php:99
$row

References $code, $i, $ilCtrlStructureReader, $ilDB, $row, clearRunningStatus(), error(), execQuery(), initGlobalsRequiredForUpdateSteps(), setCurrentVersion(), setCustomUpdatesCurrentVersion(), setHotfixCurrentVersion(), and setRunningStatus().

Referenced by applyCustomUpdates(), applyHotfix(), and applyUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkQuery()

ilDBUpdate::checkQuery (   $q)

check query

Reimplemented in ilPluginDBUpdate.

Definition at line 292 of file class.ilDBUpdate.php.

293 {
294 return true;
295 }

Referenced by execQuery().

+ Here is the caller graph for this function:

◆ clearRunningStatus()

ilDBUpdate::clearRunningStatus ( )

Clear running status.

Definition at line 203 of file class.ilDBUpdate.php.

204 {
205 include_once './Services/Administration/classes/class.ilSetting.php';
206 $set = new ilSetting("common", true);
207 $set->set("db_update_running", 0);
208 $this->db_update_running = 0;
209 }
ILIAS Setting Class.

Referenced by applyUpdateNr().

+ Here is the caller graph for this function:

◆ customUpdatesAvailable()

ilDBUpdate::customUpdatesAvailable ( )

Definition at line 798 of file class.ilDBUpdate.php.

799 {
800 // trunk does not support custom updates
801 // return false;
802
803 $this->readCustomUpdatesInfo();
804 if ($this->custom_updates_file_version > $this->custom_updates_current_version) {
805 return true;
806 }
807
808 return false;
809 }

References readCustomUpdatesInfo().

+ Here is the call graph for this function:

◆ execQuery()

ilDBUpdate::execQuery (   $db,
  $str 
)

execute a query

Parameters
objectDB
stringquery
Returns
boolean

Definition at line 246 of file class.ilDBUpdate.php.

247 {
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) != "#") {
252 //take line per line, until last char is ";"
253 if (substr($sql[$i], -1) == ";") {
254 //query is complete
255 $q .= " " . substr($sql[$i], 0, -1);
256 $check = $this->checkQuery($q);
257 if ($check === true) {
258 try {
259 $r = $db->query($q);
260 } catch (ilDatabaseException $e) {
261 var_dump($e); // FSX
262 exit;
263 $this->error = $e->getMessage();
264
265 return false;
266 }
267 } else {
268 $this->error = $check;
269
270 return false;
271 }
272 unset($q);
273 } //if
274 else {
275 $q .= " " . $sql[$i];
276 } //else
277 } //if
278 } //for
279 if ($q != "") {
280 echo "incomplete_statement: " . $q . "<br>";
281
282 return false;
283 }
284
285 return true;
286 }
exit
Definition: backend.php:16
checkQuery($q)
check query
Class ilDatabaseException.
$r
Definition: example_031.php:79

References $i, $r, checkQuery(), error(), and exit.

Referenced by applyUpdateNr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentVersion()

ilDBUpdate::getCurrentVersion ( )
Returns
int

Reimplemented in ilPluginDBUpdate.

Definition at line 145 of file class.ilDBUpdate.php.

146 {
147 include_once './Services/Administration/classes/class.ilSetting.php';
148 $set = new ilSetting("common", true);
149 $this->currentVersion = (integer) $set->get("db_version");
150
152 }

References $currentVersion.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getCustomUpdatesCurrentVersion()

ilDBUpdate::getCustomUpdatesCurrentVersion ( )

Definition at line 739 of file class.ilDBUpdate.php.

740 {
741 $this->readCustomUpdatesInfo();
742
743 return $this->custom_updates_current_version;
744 }

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCustomUpdatesFileVersion()

ilDBUpdate::getCustomUpdatesFileVersion ( )

Definition at line 757 of file class.ilDBUpdate.php.

758 {
759 $this->readCustomUpdatesInfo();
760
761 return $this->custom_updates_file_version;
762 }

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDBVersionStatus()

ilDBUpdate::getDBVersionStatus ( )

Definition at line 552 of file class.ilDBUpdate.php.

553 {
554 if ($this->fileVersion > $this->currentVersion) {
555 return false;
556 } else {
557 return true;
558 }
559 }

◆ getFileForStep()

ilDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

Parameters
int$a_version
Returns
string

Reimplemented in ilPluginDBUpdate.

Definition at line 85 of file class.ilDBUpdate.php.

86 {
87 //
88 // NOTE: IF YOU ADD A NEW FILE HERE, CHANGE ALSO THE CONSTRUCTOR
89 //
90 switch (true) {
91 case ((int) $a_version > 4182): // last number in previous file
92 return "dbupdate_04.php";
93 case ((int) $a_version > 2948): // last number in previous file
94 return "dbupdate_03.php";
95 case ((int) $a_version > 864): // last number in previous file
96 return "dbupdate_02.php";
97 default:
98 return "dbupdate.php";
99 }
100 }

Referenced by __construct(), applyUpdate(), and getUpdateSteps().

+ Here is the caller graph for this function:

◆ getFileVersion()

ilDBUpdate::getFileVersion ( )

Get Version of file.

Definition at line 232 of file class.ilDBUpdate.php.

233 {
234 return $this->fileVersion;
235 }

References $fileVersion.

◆ getHotfixCurrentVersion()

ilDBUpdate::getHotfixCurrentVersion ( )

Get current hotfix version.

Definition at line 598 of file class.ilDBUpdate.php.

599 {
600 $this->readHotfixInfo();
601
602 return $this->hotfix_current_version;
603 }

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHotfixFileVersion()

ilDBUpdate::getHotfixFileVersion ( )

Get current hotfix version.

Definition at line 625 of file class.ilDBUpdate.php.

626 {
627 $this->readHotfixInfo();
628
629 return $this->hotfix_file_version;
630 }

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHotfixSteps()

ilDBUpdate::getHotfixSteps ( )

Get hotfix steps.

Returns
string steps from the update file

Definition at line 900 of file class.ilDBUpdate.php.

901 {
902 $this->readHotfixInfo(true);
903
904 $str = "";
905
906 $f = $this->getHotfixFileVersion();
907 $c = $this->getHotfixCurrentVersion();
908
909 if ($c < $f) {
910 $msg = array();
911 for ($i = ($c + 1); $i <= $f; $i++) {
912 $this->filecontent = $this->hotfix_content;
913
914 $str .= $this->getUpdateStepNr($i, true);
915 }
916 }
917
918 return $str;
919 }
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.

References $c, $f, $i, getHotfixCurrentVersion(), getHotfixFileVersion(), getUpdateStepNr(), and readHotfixInfo().

+ Here is the call graph for this function:

◆ getRunningStatus()

ilDBUpdate::getRunningStatus ( )

Get running status.

Returns
int current runnning db step

Definition at line 190 of file class.ilDBUpdate.php.

191 {
192 include_once './Services/Administration/classes/class.ilSetting.php';
193 $set = new ilSetting("common", true);
194 $this->db_update_running = (integer) $set->get("db_update_running");
195
196 return $this->db_update_running;
197 }

◆ getTables()

ilDBUpdate::getTables ( )

Definition at line 562 of file class.ilDBUpdate.php.

563 {
564 $a = array();
565
566 $query = "SHOW TABLES";
567 $res = $this->db->query($query);
568 while ($row = $res->fetchRow()) {
569 $status = $this->getTableStatus($row[0]);
570 $a[] = array("name" => $status["Table"],
571 "table" => $row[0],
572 "status" => $status["Msg_text"],);
573 }
574
575 return $a;
576 }
getTableStatus($table)
$query
foreach($_POST as $key=> $value) $res

References $query, $res, $row, and getTableStatus().

+ Here is the call graph for this function:

◆ getTableStatus()

ilDBUpdate::getTableStatus (   $table)

Definition at line 579 of file class.ilDBUpdate.php.

580 {
581 $a = array();
582
583 $query = "ANALYZE TABLE " . $table;
584 $res = $this->db->query($query);
586
587 return $row;
588 }
if(empty($password)) $table
Definition: pwgen.php:24

References $query, $res, $row, $table, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by getTables().

+ Here is the caller graph for this function:

◆ getUpdateStepNr()

ilDBUpdate::getUpdateStepNr (   $nr,
  $hotfix = false,
  $custom_update = false 
)

Get single update step for presentation.

Definition at line 925 of file class.ilDBUpdate.php.

926 {
927 $str = "";
928
929 //search for desired $nr
930 reset($this->filecontent);
931
932 //init
933 $i = 0;
934
935 //go through filecontent
936 while (!preg_match("/^<#" . $nr . ">/", $this->filecontent[$i]) && $i < count($this->filecontent)) {
937 $i++;
938 }
939
940 //update not found
941 if ($i == count($this->filecontent)) {
942 return false;
943 }
944
945 $i++;
946
947 //update found, now extract this update to a new array
948 $update = array();
949 while ($i < count($this->filecontent) && !preg_match("/^<#" . ($nr + 1) . ">/", $this->filecontent[$i])) {
950 $str .= $this->filecontent[$i];
951 $i++;
952 }
953
954 return "<pre><b><#" . $nr . "></b>\n" . htmlentities($str) . "</pre>";
955 }

References $i.

Referenced by getHotfixSteps(), and getUpdateSteps().

+ Here is the caller graph for this function:

◆ getUpdateSteps()

ilDBUpdate::getUpdateSteps (   $a_break = 0)

Get update steps as string (for presentation)

Returns
string steps from the update file

Definition at line 860 of file class.ilDBUpdate.php.

861 {
863 $ilMySQLAbstraction = null;
864 $ilDB = null;
866
867 $str = "";
868
871
872 if ($a_break > $this->currentVersion
873 && $a_break < $this->fileVersion
874 ) {
875 $f = $a_break;
876 }
877
878 if ($c < $f) {
879 $msg = array();
880 for ($i = ($c + 1); $i <= $f; $i++) {
881 // check wether next update file must be loaded
882 if ($this->current_file != $this->getFileForStep($i)) {
883 $this->DB_UPDATE_FILE = $this->PATH . "setup/sql/" . $this->getFileForStep($i);
884 $this->readDBUpdateFile();
885 }
886
887 $str .= $this->getUpdateStepNr($i);
888 }
889 }
890
891 return $str;
892 }

References $c, $currentVersion, $f, $fileVersion, $i, $ilCtrlStructureReader, $ilDB, getFileForStep(), getUpdateStepNr(), initGlobalsRequiredForUpdateSteps(), PATH, and readDBUpdateFile().

+ Here is the call graph for this function:

◆ hotfixAvailable()

ilDBUpdate::hotfixAvailable ( )

Get status of hotfix file.

Definition at line 680 of file class.ilDBUpdate.php.

681 {
682 $this->readHotfixInfo();
683 if ($this->hotfix_file_version > $this->hotfix_current_version) {
684 return true;
685 }
686
687 return false;
688 }

References readHotfixInfo().

+ Here is the call graph for this function:

◆ initGlobalsRequiredForUpdateSteps()

ilDBUpdate::initGlobalsRequiredForUpdateSteps ( $ilCtrlStructureReader,
$ilMySQLAbstraction,
$ilDB 
)
private
Parameters
$ilCtrlStructureReader
$ilMySQLAbstraction
$ilDB

Definition at line 303 of file class.ilDBUpdate.php.

304 {
305 global $DIC;
306
307 // TODO: There is currently a huge mixup of globals, $DIC and dependencies, esprecially in setup and during DB-Updates. This leads to many problems. The following core tries to provide the needed dependencies for the dbupdate-script. The code hopefully will change in the future.
308
309 if (isset($GLOBALS['ilCtrlStructureReader'])) {
310 $ilCtrlStructureReader = $GLOBALS['ilCtrlStructureReader'];
311 } elseif ($DIC->offsetExists('ilCtrlStructureReader')) {
312 $ilCtrlStructureReader = $DIC['ilCtrlStructureReader'];
313 } else {
314 require_once 'setup/classes/class.ilCtrlStructureReader.php';
316 $DIC->offsetSet('ilCtrlStructureReader', $ilCtrlStructureReader);
317 }
318
319 $GLOBALS['ilCtrlStructureReader'] = $ilCtrlStructureReader;
320
321 if ($DIC->offsetExists('ilMySQLAbstraction')) {
322 $ilMySQLAbstraction = $DIC['ilMySQLAbstraction'];
323 } else {
324 $ilMySQLAbstraction = new ilMySQLAbstraction();
325 $DIC->offsetSet('ilMySQLAbstraction', $ilMySQLAbstraction);
326 }
327
328 $GLOBALS['ilMySQLAbstraction'] = $ilMySQLAbstraction;
329
330 if ($this->client_ini) {
331 $ilCtrlStructureReader->setIniFile($this->client_ini);
332 }
333 $ilDB = $DIC->database();
334 }
Class ilCtrlStructureReader.

References $DIC, $GLOBALS, $ilCtrlStructureReader, and $ilDB.

Referenced by applyCustomUpdates(), applyHotfix(), applyUpdate(), applyUpdateNr(), getUpdateSteps(), and loadXMLInfo().

+ Here is the caller graph for this function:

◆ initStep()

ilDBUpdate::initStep (   $i)
Parameters
int$i

Definition at line 106 of file class.ilDBUpdate.php.

107 {
108 //
109 }

Referenced by applyUpdate().

+ Here is the caller graph for this function:

◆ loadXMLInfo()

ilDBUpdate::loadXMLInfo ( )

Reimplemented in ilPluginDBUpdate.

Definition at line 392 of file class.ilDBUpdate.php.

393 {
395 $ilMySQLAbstraction = null;
396 $ilDB = null;
398
399 // read module and service information into db
400 require_once "./setup/classes/class.ilModuleReader.php";
401 require_once "./setup/classes/class.ilServiceReader.php";
402 require_once "./setup/classes/class.ilCtrlStructureReader.php";
403
404 require_once "./Services/Component/classes/class.ilModule.php";
405 require_once "./Services/Component/classes/class.ilService.php";
408
409 $ilCtrlStructureReader->readStructure();
410
411 $mr = new ilModuleReader("", "", "");
412 $mr->clearTables();
413 foreach ($modules as $module) {
414 $mr = new ilModuleReader(
415 ILIAS_ABSOLUTE_PATH . "/Modules/" . $module["subdir"] . "/module.xml",
416 $module["subdir"],
417 "Modules"
418 );
419 $mr->getModules();
420 unset($mr);
421 }
422
423 $sr = new ilServiceReader("", "", "");
424 $sr->clearTables();
425 foreach ($services as $service) {
426 $sr = new ilServiceReader(
427 ILIAS_ABSOLUTE_PATH . "/Services/" . $service["subdir"] . "/service.xml",
428 $service["subdir"],
429 "Services"
430 );
431 $sr->getServices();
432 unset($sr);
433 }
434
435
436
437 return true;
438 }
Class ilModuleReader.
static getAvailableCoreModules()
Get all available core modules.
Class ilServiceReader.
static getAvailableCoreServices()
Get all available core services.
if($modEnd===false) $module
Definition: module.php:59

References $ilCtrlStructureReader, $ilDB, $module, ilModule\getAvailableCoreModules(), ilService\getAvailableCoreServices(), and initGlobalsRequiredForUpdateSteps().

Referenced by applyCustomUpdates(), applyHotfix(), and applyUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readCustomUpdatesFileVersion()

ilDBUpdate::readCustomUpdatesFileVersion (   $a_file_content)

Definition at line 765 of file class.ilDBUpdate.php.

766 {
767 //go through filecontent and search for last occurence of <#x>
768 reset($a_file_content);
769 $regs = array();
770 foreach ($a_file_content as $row) {
771 if (preg_match("/^<#([0-9]+)>/", $row, $regs)) {
772 $version = $regs[1];
773 }
774 }
775
776 return (integer) $version;
777 }
$version
Definition: build.php:27

References $row, and $version.

Referenced by readCustomUpdatesInfo().

+ Here is the caller graph for this function:

◆ readCustomUpdatesInfo()

ilDBUpdate::readCustomUpdatesInfo (   $a_force = false)

Definition at line 780 of file class.ilDBUpdate.php.

781 {
782 if ($this->custom_updates_info_read && !$a_force) {
783 return;
784 }
785 include_once './Services/Administration/classes/class.ilSetting.php';
786
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);
792 $this->custom_updates_file_version = $this->readCustomUpdatesFileVersion($this->custom_updates_content);
793 }
794 $this->custom_updates_info_read = true;
795 }
readCustomUpdatesFileVersion($a_file_content)

References PATH, and readCustomUpdatesFileVersion().

Referenced by applyCustomUpdates(), customUpdatesAvailable(), getCustomUpdatesCurrentVersion(), getCustomUpdatesFileVersion(), and setCustomUpdatesCurrentVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readDBUpdateFile()

ilDBUpdate::readDBUpdateFile ( )

Definition at line 112 of file class.ilDBUpdate.php.

113 {
114 if (!file_exists($this->DB_UPDATE_FILE)) {
115 $this->error = "no_db_update_file";
116 $this->filecontent = array();
117
118 return false;
119 }
120
121 $this->filecontent = @file($this->DB_UPDATE_FILE);
122
123 return true;
124 }

References error().

Referenced by ilPluginDBUpdate\__construct(), __construct(), applyUpdate(), and getUpdateSteps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readFileVersion()

ilDBUpdate::readFileVersion ( )

Definition at line 212 of file class.ilDBUpdate.php.

213 {
214 //go through filecontent and search for last occurence of <#x>
215 reset($this->lastfilecontent);
216 $regs = array();
217 foreach ($this->lastfilecontent as $row) {
218 if (preg_match('/^<\#([0-9]+)>/', $row, $regs)) {
219 $version = $regs[1];
220 }
221 }
222
223 $this->fileVersion = (integer) $version;
224
225 return $this->fileVersion;
226 }

References $fileVersion, $row, and $version.

Referenced by ilPluginDBUpdate\__construct(), and __construct().

+ Here is the caller graph for this function:

◆ readHotfixFileVersion()

ilDBUpdate::readHotfixFileVersion (   $a_file_content)

Set current hotfix version.

Definition at line 636 of file class.ilDBUpdate.php.

637 {
638 //go through filecontent and search for last occurence of <#x>
639 reset($a_file_content);
640 $regs = array();
641 foreach ($a_file_content as $row) {
642 if (preg_match("/^<#([0-9]+)>/", $row, $regs)) {
643 $version = $regs[1];
644 }
645 }
646
647 return (integer) $version;
648 }

References $row, and $version.

Referenced by readHotfixInfo().

+ Here is the caller graph for this function:

◆ readHotfixInfo()

ilDBUpdate::readHotfixInfo (   $a_force = false)

Get status of hotfix file.

Definition at line 654 of file class.ilDBUpdate.php.

655 {
656 if ($this->hotfix_info_read && !$a_force) {
657 return;
658 }
659 include_once './Services/Administration/classes/class.ilSetting.php';
660 $this->hotfix_setting = new ilSetting("common", true);
661 $ilias_version = ILIAS_VERSION_NUMERIC;
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]
670 );
671 $this->hotfix_file_version = $this->readHotfixFileVersion($this->hotfix_content);
672 }
673 $this->hotfix_info_read = true;
674 }
readHotfixFileVersion($a_file_content)
Set current hotfix version.
const ILIAS_VERSION_NUMERIC

References ILIAS_VERSION_NUMERIC, PATH, and readHotfixFileVersion().

Referenced by applyHotfix(), getHotfixCurrentVersion(), getHotfixFileVersion(), getHotfixSteps(), hotfixAvailable(), and setHotfixCurrentVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readLastUpdateFile()

ilDBUpdate::readLastUpdateFile ( )

Definition at line 127 of file class.ilDBUpdate.php.

128 {
129 if (!file_exists($this->LAST_UPDATE_FILE)) {
130 $this->error = "no_last_update_file";
131 $this->lastfilecontent = array();
132
133 return false;
134 }
135
136 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
137
138 return true;
139 }

References error().

Referenced by ilPluginDBUpdate\__construct(), and __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentVersion()

ilDBUpdate::setCurrentVersion (   $a_version)
Parameters
int$a_version
Returns
bool

Reimplemented in ilPluginDBUpdate.

Definition at line 160 of file class.ilDBUpdate.php.

161 {
162 include_once './Services/Administration/classes/class.ilSetting.php';
163 $set = new ilSetting("common", true);
164 $set->set("db_version", $a_version);
165 $this->currentVersion = $a_version;
166
167 return true;
168 }

Referenced by applyUpdateNr().

+ Here is the caller graph for this function:

◆ setCustomUpdatesCurrentVersion()

ilDBUpdate::setCustomUpdatesCurrentVersion (   $a_version)

Definition at line 747 of file class.ilDBUpdate.php.

748 {
749 $this->readCustomUpdatesInfo();
750 $this->custom_updates_setting->set('db_version_custom', $a_version);
751 $this->custom_updates_current_version = $a_version;
752
753 return true;
754 }

References readCustomUpdatesInfo().

Referenced by applyUpdateNr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHotfixCurrentVersion()

ilDBUpdate::setHotfixCurrentVersion (   $a_version)

Set current hotfix version.

Definition at line 609 of file class.ilDBUpdate.php.

610 {
611 $this->readHotfixInfo();
612 $this->hotfix_setting->set(
613 "db_hotfixes_" . $this->hotfix_version[0] . "_" . $this->hotfix_version[1],
614 $a_version
615 );
616 $this->hotfix_current_version = $a_version;
617
618 return true;
619 }

References readHotfixInfo().

Referenced by applyUpdateNr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRunningStatus()

ilDBUpdate::setRunningStatus (   $a_nr)

Set running status for a step.

Parameters
intstep number

Definition at line 176 of file class.ilDBUpdate.php.

177 {
178 include_once './Services/Administration/classes/class.ilSetting.php';
179 $set = new ilSetting("common", true);
180 $set->set("db_update_running", $a_nr);
181 $this->db_update_running = $a_nr;
182 }

Referenced by applyUpdateNr().

+ Here is the caller graph for this function:

Field Documentation

◆ $currentVersion

ilDBUpdate::$currentVersion

◆ $DB_UPDATE_FILE

ilDBUpdate::$DB_UPDATE_FILE

db update file

Definition at line 18 of file class.ilDBUpdate.php.

◆ $fileVersion

ilDBUpdate::$fileVersion

Definition at line 30 of file class.ilDBUpdate.php.

Referenced by applyUpdate(), getFileVersion(), getUpdateSteps(), and readFileVersion().

◆ $updateMsg

ilDBUpdate::$updateMsg

Definition at line 34 of file class.ilDBUpdate.php.


The documentation for this class was generated from the following file: