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.

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

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.
global $DIC
Definition: saml.php:7
const PATH
Definition: proxy_ylocal.php:8
+ Here is the call graph for this function:

Member Function Documentation

◆ applyCustomUpdates()

ilDBUpdate::applyCustomUpdates ( )

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

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

Referenced by ilSetupGUI\applyCustomUpdates().

813  {
814  $ilCtrlStructureReader = null;
815  $ilMySQLAbstraction = null;
816  $ilDB = null;
817  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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 
826  $f = $this->getCustomUpdatesFileVersion();
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  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$ilCtrlStructureReader
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
readCustomUpdatesInfo($a_force=false)
global $ilDB
$i
Definition: disco.tpl.php:19
getCustomUpdatesCurrentVersion()
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyHotfix()

ilDBUpdate::applyHotfix ( )

Apply hotfix.

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

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

Referenced by ilSetupGUI\applyHotfix().

695  {
696  $ilCtrlStructureReader = null;
697  $ilMySQLAbstraction = null;
698  $ilDB = null;
699  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$ilCtrlStructureReader
getHotfixFileVersion()
Get current hotfix version.
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
readHotfixInfo($a_force=false)
Get status of hotfix file.
getHotfixCurrentVersion()
Get current hotfix version.
global $ilDB
$i
Definition: disco.tpl.php:19
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyUpdate()

ilDBUpdate::applyUpdate (   $a_break = 0)

Apply update.

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

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

Referenced by ilSetupGUI\updateDatabase().

341  {
342  $ilCtrlStructureReader = null;
343  $ilMySQLAbstraction = null;
344  $ilDB = null;
345  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
getFileForStep($a_version)
Get db update file name for db step.
$ilCtrlStructureReader
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
const PATH
Definition: proxy_ylocal.php:8
global $ilDB
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller 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 private

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

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

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

450  {
451  $ilCtrlStructureReader = null;
452  $ilMySQLAbstraction = null;
453  $ilDB = null;
454  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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) {
539  $this->setCustomUpdatesCurrentVersion($nr);
540  }
541 
542  if (!$hotfix && !$custom_update) {
543  $this->clearRunningStatus();
544  }
545 
546  //$this->currentVersion = $ilias->getSetting("db_version");
547 
548  return true;
549  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
setRunningStatus($a_nr)
Set running status for a step.
$code
Definition: example_050.php:99
$ilCtrlStructureReader
setCustomUpdatesCurrentVersion($a_version)
execQuery($db, $str)
execute a query
setHotfixCurrentVersion($a_version)
Set current hotfix version.
$row
setCurrentVersion($a_version)
global $ilDB
$i
Definition: disco.tpl.php:19
clearRunningStatus()
Clear running status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkQuery()

ilDBUpdate::checkQuery (   $q)

check query

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

Referenced by execQuery().

293  {
294  return true;
295  }
+ Here is the caller graph for this function:

◆ clearRunningStatus()

ilDBUpdate::clearRunningStatus ( )

Clear running status.

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

Referenced by applyUpdateNr().

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  }
+ Here is the caller graph for this function:

◆ customUpdatesAvailable()

ilDBUpdate::customUpdatesAvailable ( )

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

References readCustomUpdatesInfo().

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  }
readCustomUpdatesInfo($a_force=false)
+ 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.

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

Referenced by applyUpdateNr().

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  }
Class ilDatabaseException.
$r
Definition: example_031.php:79
checkQuery($q)
check query
exit
Definition: backend.php:16
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentVersion()

ilDBUpdate::getCurrentVersion ( )
Returns
int

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

References $currentVersion.

Referenced by __construct().

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 
151  return $this->currentVersion;
152  }
+ Here is the caller graph for this function:

◆ getCustomUpdatesCurrentVersion()

ilDBUpdate::getCustomUpdatesCurrentVersion ( )

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

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

740  {
741  $this->readCustomUpdatesInfo();
742 
743  return $this->custom_updates_current_version;
744  }
readCustomUpdatesInfo($a_force=false)
+ 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.

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

758  {
759  $this->readCustomUpdatesInfo();
760 
761  return $this->custom_updates_file_version;
762  }
readCustomUpdatesInfo($a_force=false)
+ 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

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

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

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  }
+ Here is the caller graph for this function:

◆ getFileVersion()

ilDBUpdate::getFileVersion ( )

Get Version of file.

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

References $fileVersion.

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

◆ getHotfixCurrentVersion()

ilDBUpdate::getHotfixCurrentVersion ( )

Get current hotfix version.

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

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

599  {
600  $this->readHotfixInfo();
601 
602  return $this->hotfix_current_version;
603  }
readHotfixInfo($a_force=false)
Get status of hotfix file.
+ 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.

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

626  {
627  $this->readHotfixInfo();
628 
629  return $this->hotfix_file_version;
630  }
readHotfixInfo($a_force=false)
Get status of hotfix file.
+ 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.

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

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  }
getHotfixFileVersion()
Get current hotfix version.
readHotfixInfo($a_force=false)
Get status of hotfix file.
getHotfixCurrentVersion()
Get current hotfix version.
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.
$i
Definition: disco.tpl.php:19
+ 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.

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

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)
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the call graph for this function:

◆ getTableStatus()

ilDBUpdate::getTableStatus (   $table)

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

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

Referenced by getTables().

580  {
581  $a = array();
582 
583  $query = "ANALYZE TABLE " . $table;
584  $res = $this->db->query($query);
586 
587  return $row;
588  }
foreach($_POST as $key=> $value) $res
$query
$row
if(empty($password)) $table
Definition: pwgen.php:24
+ 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.

References $i.

Referenced by getHotfixSteps(), and getUpdateSteps().

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  }
$i
Definition: disco.tpl.php:19
+ 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.

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

861  {
862  $ilCtrlStructureReader = null;
863  $ilMySQLAbstraction = null;
864  $ilDB = null;
865  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
getFileForStep($a_version)
Get db update file name for db step.
$ilCtrlStructureReader
const PATH
Definition: proxy_ylocal.php:8
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.
global $ilDB
$i
Definition: disco.tpl.php:19
+ 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.

References readHotfixInfo().

681  {
682  $this->readHotfixInfo();
683  if ($this->hotfix_file_version > $this->hotfix_current_version) {
684  return true;
685  }
686 
687  return false;
688  }
readHotfixInfo($a_force=false)
Get status of hotfix file.
+ 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.

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

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

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  }
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
global $DIC
Definition: saml.php:7
$ilCtrlStructureReader
Class ilCtrlStructureReader.
global $ilDB
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ initStep()

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

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

Referenced by applyUpdate().

107  {
108  //
109  }
+ Here is the caller graph for this function:

◆ loadXMLInfo()

ilDBUpdate::loadXMLInfo ( )

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

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

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

393  {
394  $ilCtrlStructureReader = null;
395  $ilMySQLAbstraction = null;
396  $ilDB = null;
397  $this->initGlobalsRequiredForUpdateSteps($ilCtrlStructureReader, $ilMySQLAbstraction, $ilDB);
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  }
initGlobalsRequiredForUpdateSteps(&$ilCtrlStructureReader, &$ilMySQLAbstraction, &$ilDB)
Class ilServiceReader.
$ilCtrlStructureReader
if($modEnd===false) $module
Definition: module.php:59
static getAvailableCoreServices()
Get all available core services.
global $ilDB
Class ilModuleReader.
static getAvailableCoreModules()
Get all available core modules.
+ 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.

References $row, and $version.

Referenced by readCustomUpdatesInfo().

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
$row
+ Here is the caller graph for this function:

◆ readCustomUpdatesInfo()

ilDBUpdate::readCustomUpdatesInfo (   $a_force = false)

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

References PATH, and readCustomUpdatesFileVersion().

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

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  }
const PATH
Definition: proxy_ylocal.php:8
readCustomUpdatesFileVersion($a_file_content)
+ 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.

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

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  }
+ Here is the caller graph for this function:

◆ readFileVersion()

ilDBUpdate::readFileVersion ( )

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

References $fileVersion, $row, and $version.

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

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  }
$version
Definition: build.php:27
$row
+ 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.

References $row, and $version.

Referenced by readHotfixInfo().

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  }
$version
Definition: build.php:27
$row
+ 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.

References ILIAS_VERSION_NUMERIC, PATH, and readHotfixFileVersion().

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

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  }
const ILIAS_VERSION_NUMERIC
const PATH
Definition: proxy_ylocal.php:8
readHotfixFileVersion($a_file_content)
Set current hotfix version.
+ 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.

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

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  }
+ Here is the caller graph for this function:

◆ setCurrentVersion()

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

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

Referenced by applyUpdateNr().

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  }
+ Here is the caller graph for this function:

◆ setCustomUpdatesCurrentVersion()

ilDBUpdate::setCustomUpdatesCurrentVersion (   $a_version)

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

References readCustomUpdatesInfo().

Referenced by applyUpdateNr().

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  }
readCustomUpdatesInfo($a_force=false)
+ 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.

References readHotfixInfo().

Referenced by applyUpdateNr().

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  }
readHotfixInfo($a_force=false)
Get status of hotfix file.
+ 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.

Referenced by applyUpdateNr().

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  }
+ 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: