ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDBUpdate Class Reference

Database Update class. More...

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

Public Member Functions

 __construct ($a_db_handler=0, $tmp_flag=false)
 constructor More...
 
 getFileForStep ($a_version)
 Get db update file name for db step. More...
 
 initStep ($i)
 Init Step. More...
 
 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
 

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,
  $tmp_flag = false 
)

constructor

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

References getCurrentVersion(), getFileForStep(), readDBUpdateFile(), readFileVersion(), and readLastUpdateFile().

35  {
36  // workaround to allow setup migration
37  if ($a_db_handler)
38  {
39  $this->db =& $a_db_handler;
40 
41  if ($tmp_flag)
42  {
43  $this->PATH = "./";
44  }
45  else
46  {
47  $this->PATH = "./";
48  //$this->PATH = "../";
49  }
50  }
51  else
52  {
53  global $mySetup;
54  $this->db = $mySetup->db;
55  $this->PATH = "./";
56  }
57 
58  $this->getCurrentVersion();
59 
60  // get update file for current version
61  $updatefile = $this->getFileForStep($this->currentVersion + 1);
62 
63  $this->current_file = $updatefile;
64  $this->DB_UPDATE_FILE = $this->PATH."setup/sql/".$updatefile;
65 
66  //
67  // NOTE: IF YOU SET THIS TO THE NEWEST FILE, CHANGE ALSO getFileForStep()
68  //
69  $this->LAST_UPDATE_FILE = $this->PATH."setup/sql/dbupdate_04.php";
70 
71  $this->readDBUpdateFile();
72  $this->readLastUpdateFile();
73  $this->readFileVersion();
74  }
getFileForStep($a_version)
Get db update file name for db step.
+ Here is the call graph for this function:

Member Function Documentation

◆ applyCustomUpdates()

ilDBUpdate::applyCustomUpdates ( )

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

References $GLOBALS, $ilCtrlStructureReader, applyUpdateNr(), array, getCustomUpdatesCurrentVersion(), getCustomUpdatesFileVersion(), loadXMLInfo(), and readCustomUpdatesInfo().

767  {
768  global $ilCtrlStructureReader, $ilMySQLAbstraction;
769 
770  include_once './Services/Database/classes/class.ilMySQLAbstraction.php';
771 
772  $ilMySQLAbstraction = new ilMySQLAbstraction();
773  $GLOBALS['ilMySQLAbstraction'] = $ilMySQLAbstraction;
774 
775  $this->readCustomUpdatesInfo(true);
776 
777  $f = $this->getCustomUpdatesFileVersion();
778  $c = $this->getCustomUpdatesCurrentVersion();
779 
780  if ($c < $f)
781  {
782  $msg = array();
783  for ($i=($c+1); $i<=$f; $i++)
784  {
785 // $this->initStep($i); // nothings happens here
786 
787  $this->filecontent = $this->custom_updates_content;
788 
789  if ($this->applyUpdateNr($i, false, true) == false)
790  {
791  $msg[] = array(
792  "msg" => "update_error: ".$this->error,
793  "nr" => $i
794  );
795  $this->updateMsg = $msg;
796  return false;
797  }
798  else
799  {
800  $msg[] = array(
801  "msg" => "custom_update_applied",
802  "nr" => $i
803  );
804  }
805  }
806 
807  $this->updateMsg = $msg;
808  }
809  else
810  {
811  $this->updateMsg = "no_changes";
812  }
813 
814  return $this->loadXMLInfo();
815  }
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ilCtrlStructureReader
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
Create styles array
The data for the language used.
readCustomUpdatesInfo($a_force=false)
getCustomUpdatesCurrentVersion()
+ Here is the call graph for this function:

◆ applyHotfix()

ilDBUpdate::applyHotfix ( )

Apply hotfix.

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

References $GLOBALS, $ilCtrlStructureReader, applyUpdateNr(), array, getHotfixCurrentVersion(), getHotfixFileVersion(), loadXMLInfo(), and readHotfixInfo().

648  {
649  global $ilCtrlStructureReader, $ilMySQLAbstraction;
650 
651  include_once './Services/Database/classes/class.ilMySQLAbstraction.php';
652 
653  $ilMySQLAbstraction = new ilMySQLAbstraction();
654  $GLOBALS['ilMySQLAbstraction'] = $ilMySQLAbstraction;
655 
656  $this->readHotfixInfo(true);
657 
658  $f = $this->getHotfixFileVersion();
659  $c = $this->getHotfixCurrentVersion();
660 
661  if ($c < $f)
662  {
663  $msg = array();
664  for ($i=($c+1); $i<=$f; $i++)
665  {
666 // $this->initStep($i); // nothings happens here
667 
668  $this->filecontent = $this->hotfix_content;
669 
670  if ($this->applyUpdateNr($i, true) == false)
671  {
672  $msg[] = array(
673  "msg" => "update_error: ".$this->error,
674  "nr" => $i
675  );
676  $this->updateMsg = $msg;
677  return false;
678  }
679  else
680  {
681  $msg[] = array(
682  "msg" => "hotfix_applied",
683  "nr" => $i
684  );
685  }
686  }
687 
688  $this->updateMsg = $msg;
689  }
690  else
691  {
692  $this->updateMsg = "no_changes";
693  }
694 
695  return $this->loadXMLInfo();
696  }
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$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.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ applyUpdate()

ilDBUpdate::applyUpdate (   $a_break = 0)

Apply update.

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

References $currentVersion, $fileVersion, $GLOBALS, $ilCtrlStructureReader, applyUpdateNr(), array, getFileForStep(), initStep(), loadXMLInfo(), and readDBUpdateFile().

283  {
284  global $ilCtrlStructureReader, $ilMySQLAbstraction;
285 
286  include_once './Services/Database/classes/class.ilMySQLAbstraction.php';
287 
288  $ilMySQLAbstraction = new ilMySQLAbstraction();
289  $GLOBALS['ilMySQLAbstraction'] = $ilMySQLAbstraction;
290 
291  $f = $this->fileVersion;
293 
294  if ($a_break > $this->currentVersion &&
295  $a_break < $this->fileVersion)
296  {
297  $f = $a_break;
298  }
299 
300  if ($c < $f)
301  {
302  $msg = array();
303  for ($i=($c+1); $i<=$f; $i++)
304  {
305  // check wether next update file must be loaded
306  if ($this->current_file != $this->getFileForStep($i))
307  {
308  $this->DB_UPDATE_FILE = $this->PATH."setup/sql/".$this->getFileForStep($i);
309  $this->readDBUpdateFile();
310  }
311 
312  $this->initStep($i);
313 
314  if ($this->applyUpdateNr($i) == false)
315  {
316  $msg[] = array(
317  "msg" => "update_error: ".$this->error,
318  "nr" => $i
319  );
320  $this->updateMsg = $msg;
321  return false;
322  }
323  else
324  {
325  $msg[] = array(
326  "msg" => "update_applied",
327  "nr" => $i
328  );
329  }
330  }
331 
332  $this->updateMsg = $msg;
333  }
334  else
335  {
336  $this->updateMsg = "no_changes";
337  }
338 
339  if ($f < $this->fileVersion)
340  {
341  return true;
342  }
343  else
344  {
345  return $this->loadXMLInfo();
346  }
347  }
getFileForStep($a_version)
Get db update file name for db step.
This class includes methods that help to abstract ILIAS 3.10.x MySQL tables for the use with MDB2 abs...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$ilCtrlStructureReader
applyUpdateNr($nr, $hotfix=false, $custom_update=false)
apply an update
initStep($i)
Init Step.
Create styles array
The data for the language used.
+ 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 private

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

References $code, $error, $ilCtrlStructureReader, $ilDB, $ilErr, $ilUser, $php, $row, array, clearRunningStatus(), execQuery(), setCurrentVersion(), setCustomUpdatesCurrentVersion(), setHotfixCurrentVersion(), and setRunningStatus().

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

395  {
396  global $ilDB,$ilErr,$ilUser,$ilCtrlStructureReader,$ilModuleReader,$ilMySQLAbstraction;
397 
398  //search for desired $nr
399  reset($this->filecontent);
400 
401  if (!$hotfix && !$custom_update)
402  {
403  $this->setRunningStatus($nr);
404  }
405 
406  //init
407  $i = 0;
408 
409  //go through filecontent
410  while (!preg_match("/^<\#".$nr.">/", $this->filecontent[$i]) && $i<count($this->filecontent))
411  {
412  $i++;
413  }
414 
415  //update not found
416  if ($i == count($this->filecontent))
417  {
418  $this->error = "update_not_found";
419  return false;
420  }
421 
422  $i++;
423 
424  //update found, now extract this update to a new array
425  $update = array();
426  while ($i<count($this->filecontent) && !preg_match("/^<#".($nr+1).">/", $this->filecontent[$i]))
427  {
428  $update[] = trim($this->filecontent[$i]);
429  $i++;
430  }
431 
432  //now you have the update, now process it
433  $sql = array();
434  $php = array();
435  $mode = "sql";
436 
437  foreach ($update as $row)
438  {
439  if (preg_match("/<\?php/", $row))
440  {
441  if (count($sql)>0)
442  {
443  if ($this->execQuery($this->db, implode("\n", $sql)) == false)
444  {
445  $this->error = $this->error;
446  return false;
447  }
448  $sql = array();
449  }
450  $mode = "php";
451  }
452  elseif (preg_match("/\?>/", $row))
453  {
454  if (count($php)>0)
455  {
456  $code = implode("\n", $php);
457  if (eval($code) === false)
458  {
459  $this->error = "Parse error: ".$code;
460  return false;
461  }
462  $php = array();
463  }
464  $mode = "sql";
465 
466  }
467  else
468  {
469  if ($mode == "sql")
470  {
471  $sql[] = $row;
472  }
473 
474  if ($mode == "php")
475  {
476  $php[] = $row;
477  }
478  } //else
479  } //foreach
480 
481  if ($mode == "sql" && count($sql) > 0)
482  {
483  if ($this->execQuery($this->db, implode("\n", $sql)) == false)
484  {
485  $this->error = "dump_error: ".$this->error;
486  return false;
487  }
488  }
489 
490  //increase db_Version number
491  if (!$hotfix && !$custom_update)
492  {
493  $this->setCurrentVersion($nr);
494  }
495  elseif($hotfix)
496  {
497  $this->setHotfixCurrentVersion($nr);
498  }
499  elseif($custom_update)
500  {
501  $this->setCustomUpdatesCurrentVersion($nr);
502  }
503 
504  if (!$hotfix && !$custom_update)
505  {
506  $this->clearRunningStatus();
507  }
508  //$this->currentVersion = $ilias->getSetting("db_version");
509 
510  return true;
511 
512  }
global $ilErr
Definition: raiseError.php:16
$error
Definition: Error.php:17
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.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
setCurrentVersion($a_version)
global $ilDB
clearRunningStatus()
Clear running status.
$php
Definition: flush.php:22
+ 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 274 of file class.ilDBUpdate.php.

Referenced by execQuery().

275  {
276  return true;
277  }
+ Here is the caller graph for this function:

◆ clearRunningStatus()

ilDBUpdate::clearRunningStatus ( )

Clear running status.

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

Referenced by applyUpdateNr().

186  {
187  include_once './Services/Administration/classes/class.ilSetting.php';
188  $set = new ilSetting("common", true);
189  $set->set("db_update_running", 0);
190  $this->db_update_running = 0;
191  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ customUpdatesAvailable()

ilDBUpdate::customUpdatesAvailable ( )

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

References readCustomUpdatesInfo().

754  {
755  // trunk does not support custom updates
756 // return false;
757 
758  $this->readCustomUpdatesInfo();
759  if ($this->custom_updates_file_version > $this->custom_updates_current_version)
760  {
761  return true;
762  }
763  return false;
764  }
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 224 of file class.ilDBUpdate.php.

References $r, checkQuery(), and exit.

Referenced by applyUpdateNr().

225  {
226  $sql = explode("\n",trim($str));
227  for ($i=0; $i<count($sql); $i++)
228  {
229  $sql[$i] = trim($sql[$i]);
230  if ($sql[$i] != "" && substr($sql[$i],0,1)!="#")
231  {
232  //take line per line, until last char is ";"
233  if (substr($sql[$i],-1)==";")
234  {
235  //query is complete
236  $q .= " ".substr($sql[$i],0,-1);
237  $check = $this->checkQuery($q);
238  if ($check === true)
239  {
240  try {
241  $r = $db->query($q);
242  } catch (ilDatabaseException $e) {
243  var_dump($e); // FSX
244  exit;
245  $this->error = $e->getMessage();
246 
247  return false;
248  }
249  }
250  else
251  {
252  $this->error = $check;
253  return false;
254  }
255  unset($q);
256  } //if
257  else
258  {
259  $q .= " ".$sql[$i];
260  } //else
261  } //if
262  } //for
263  if ($q != "")
264  {
265  echo "incomplete_statement: ".$q."<br>";
266  return false;
267  }
268  return true;
269  }
Class ilDatabaseException.
$r
Definition: example_031.php:79
checkQuery($q)
check query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentVersion()

ilDBUpdate::getCurrentVersion ( )

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

References $currentVersion.

Referenced by __construct().

138  {
139  include_once './Services/Administration/classes/class.ilSetting.php';
140  $set = new ilSetting("common", true);
141  $this->currentVersion = (integer) $set->get("db_version");
142  return $this->currentVersion;
143  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ getCustomUpdatesCurrentVersion()

ilDBUpdate::getCustomUpdatesCurrentVersion ( )

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

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

699  {
700  $this->readCustomUpdatesInfo();
701  return $this->custom_updates_current_version;
702  }
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 712 of file class.ilDBUpdate.php.

References readCustomUpdatesInfo().

Referenced by applyCustomUpdates().

713  {
714  $this->readCustomUpdatesInfo();
715  return $this->custom_updates_file_version;
716  }
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 514 of file class.ilDBUpdate.php.

515  {
516  if ($this->fileVersion > $this->currentVersion)
517  return false;
518  else
519  return true;
520  }

◆ getFileForStep()

ilDBUpdate::getFileForStep (   $a_version)

Get db update file name for db step.

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

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

80  {
81  //
82  // NOTE: IF YOU ADD A NEW FILE HERE, CHANGE ALSO THE CONSTRUCTOR
83  //
84  if ((int)$a_version > 4182) // last number in previous file
85  {
86  return "dbupdate_04.php";
87  }
88  else if ((int)$a_version > 2948) // last number in previous file
89  {
90  return "dbupdate_03.php";
91  }
92  else if ((int)$a_version > 864) // last number in previous file
93  {
94  return "dbupdate_02.php";
95  }
96  else
97  {
98  return "dbupdate.php";
99  }
100  }
+ Here is the caller graph for this function:

◆ getFileVersion()

ilDBUpdate::getFileVersion ( )

Get Version of file.

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

References $fileVersion.

214  {
215  return $this->fileVersion;
216  }

◆ getHotfixCurrentVersion()

ilDBUpdate::getHotfixCurrentVersion ( )

Get current hotfix version.

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

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

560  {
561  $this->readHotfixInfo();
562  return $this->hotfix_current_version;
563  }
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 580 of file class.ilDBUpdate.php.

References readHotfixInfo().

Referenced by applyHotfix(), and getHotfixSteps().

581  {
582  $this->readHotfixInfo();
583  return $this->hotfix_file_version;
584  }
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 861 of file class.ilDBUpdate.php.

References array, getHotfixCurrentVersion(), getHotfixFileVersion(), getUpdateStepNr(), and readHotfixInfo().

862  {
863  $this->readHotfixInfo(true);
864 
865  $str = "";
866 
867  $f = $this->getHotfixFileVersion();
868  $c = $this->getHotfixCurrentVersion();
869 
870  if ($c < $f)
871  {
872  $msg = array();
873  for ($i=($c+1); $i<=$f; $i++)
874  {
875  $this->filecontent = $this->hotfix_content;
876 
877  $str.= $this->getUpdateStepNr($i, true);
878  }
879  }
880 
881  return $str;
882  }
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.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getRunningStatus()

ilDBUpdate::getRunningStatus ( )

Get running status.

Returns
int current runnning db step

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

174  {
175  include_once './Services/Administration/classes/class.ilSetting.php';
176  $set = new ilSetting("common", true);
177  $this->db_update_running = (integer) $set->get("db_update_running");
178 
179  return $this->db_update_running;
180  }
ILIAS Setting Class.

◆ getTables()

ilDBUpdate::getTables ( )

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

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

523  {
524  $a = array();
525 
526  $query = "SHOW TABLES";
527  $res = $this->db->query($query);
528  while ($row = $res->fetchRow())
529  {
530  $status = $this->getTableStatus($row[0]);
531  $a[] = array(
532  "name" => $status["Table"],
533  "table" => $row[0],
534  "status" => $status["Msg_text"]
535  );
536  }
537  return $a;
538  }
getTableStatus($table)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getTableStatus()

ilDBUpdate::getTableStatus (   $table)

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

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

Referenced by getTables().

541  {
542  $a = array();
543 
544  $query = "ANALYZE TABLE ".$table;
545  $res = $this->db->query($query);
547  return $row;
548  }
Create styles array
The data for the language used.
+ 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 888 of file class.ilDBUpdate.php.

References $ilCtrlStructureReader, $ilDB, $ilErr, $ilUser, and array.

Referenced by getHotfixSteps(), and getUpdateSteps().

889  {
890  global $ilDB,$ilErr,$ilUser,$ilCtrlStructureReader,$ilModuleReader,$ilMySQLAbstraction;
891 
892  $str = "";
893 
894  //search for desired $nr
895  reset($this->filecontent);
896 
897  //init
898  $i = 0;
899 
900  //go through filecontent
901  while (!preg_match("/^<#".$nr.">/", $this->filecontent[$i]) && $i<count($this->filecontent))
902  {
903  $i++;
904  }
905 
906  //update not found
907  if ($i == count($this->filecontent))
908  {
909  return false;
910  }
911 
912  $i++;
913 
914  //update found, now extract this update to a new array
915  $update = array();
916  while ($i<count($this->filecontent) && !preg_match("/^<#".($nr+1).">/", $this->filecontent[$i]))
917  {
918  $str.= $this->filecontent[$i];
919  $i++;
920  }
921 
922  return "<pre><b><#".$nr."></b>\n".htmlentities($str)."</pre>";
923  }
global $ilErr
Definition: raiseError.php:16
$ilCtrlStructureReader
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ 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 822 of file class.ilDBUpdate.php.

References $currentVersion, $fileVersion, $ilCtrlStructureReader, array, getFileForStep(), getUpdateStepNr(), and readDBUpdateFile().

823  {
824  global $ilCtrlStructureReader, $ilMySQLAbstraction;
825 
826  $str = "";
827 
828  $f = $this->fileVersion;
830 
831  if ($a_break > $this->currentVersion &&
832  $a_break < $this->fileVersion)
833  {
834  $f = $a_break;
835  }
836 
837  if ($c < $f)
838  {
839  $msg = array();
840  for ($i=($c+1); $i<=$f; $i++)
841  {
842  // check wether next update file must be loaded
843  if ($this->current_file != $this->getFileForStep($i))
844  {
845  $this->DB_UPDATE_FILE = $this->PATH."setup/sql/".$this->getFileForStep($i);
846  $this->readDBUpdateFile();
847  }
848 
849  $str.= $this->getUpdateStepNr($i);
850  }
851 
852  }
853  return $str;
854  }
getFileForStep($a_version)
Get db update file name for db step.
$ilCtrlStructureReader
getUpdateStepNr($nr, $hotfix=false, $custom_update=false)
Get single update step for presentation.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ hotfixAvailable()

ilDBUpdate::hotfixAvailable ( )

Get status of hotfix file.

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

References readHotfixInfo().

635  {
636  $this->readHotfixInfo();
637  if ($this->hotfix_file_version > $this->hotfix_current_version)
638  {
639  return true;
640  }
641  return false;
642  }
readHotfixInfo($a_force=false)
Get status of hotfix file.
+ Here is the call graph for this function:

◆ initStep()

ilDBUpdate::initStep (   $i)

Init Step.

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

Referenced by applyUpdate().

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

◆ loadXMLInfo()

ilDBUpdate::loadXMLInfo ( )

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

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

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

350  {
351  global $ilCtrlStructureReader;
352 
353  // read module and service information into db
354  require_once "./setup/classes/class.ilModuleReader.php";
355  require_once "./setup/classes/class.ilServiceReader.php";
356  require_once "./setup/classes/class.ilCtrlStructureReader.php";
357 
358  require_once "./Services/Component/classes/class.ilModule.php";
359  require_once "./Services/Component/classes/class.ilService.php";
362 
363  $mr = new ilModuleReader("", "", "");
364  $mr->clearTables();
365  foreach($modules as $module)
366  {
367  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
368  $module["subdir"], "Modules");
369  $mr->getModules();
370  unset($mr);
371  }
372 
373  $sr = new ilServiceReader("", "", "");
374  $sr->clearTables();
375  foreach($services as $service)
376  {
377  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
378  $service["subdir"], "Services");
379  $sr->getServices();
380  unset($sr);
381  }
382 
383  $ilCtrlStructureReader->readStructure();
384 
385  return true;
386  }
Class ilServiceReader.
$ilCtrlStructureReader
static getAvailableCoreServices()
Get all available core services.
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 718 of file class.ilDBUpdate.php.

References $row, $version, and array.

Referenced by readCustomUpdatesInfo().

719  {
720  //go through filecontent and search for last occurence of <#x>
721  reset($a_file_content);
722  $regs = array();
723  foreach ($a_file_content as $row)
724  {
725  if (preg_match("/^<#([0-9]+)>/", $row, $regs))
726  {
727  $version = $regs[1];
728  }
729  }
730 
731  return (integer) $version;
732  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readCustomUpdatesInfo()

ilDBUpdate::readCustomUpdatesInfo (   $a_force = false)

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

References file, and readCustomUpdatesFileVersion().

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

735  {
736  if ($this->custom_updates_info_read && !$a_force)
737  {
738  return;
739  }
740  include_once './Services/Administration/classes/class.ilSetting.php';
741 
742  $this->custom_updates_setting = new ilSetting();
743  $custom_updates_file = $this->PATH."setup/sql/dbupdate_custom.php";
744  if (is_file($custom_updates_file))
745  {
746  $this->custom_updates_content = @file($custom_updates_file);
747  $this->custom_updates_current_version = (int) $this->custom_updates_setting->get('db_version_custom', 0);
748  $this->custom_updates_file_version = $this->readCustomUpdatesFileVersion($this->custom_updates_content);
749  }
750  $this->custom_updates_info_read = true;
751  }
ILIAS Setting Class.
readCustomUpdatesFileVersion($a_file_content)
Reload workbook from saved file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readDBUpdateFile()

ilDBUpdate::readDBUpdateFile ( )

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

References array, and file.

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

112  {
113  if (!file_exists($this->DB_UPDATE_FILE))
114  {
115  $this->error = "no_db_update_file";
116  $this->filecontent = array();
117  return false;
118  }
119 
120  $this->filecontent = @file($this->DB_UPDATE_FILE);
121  return true;
122  }
Reload workbook from saved file
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readFileVersion()

ilDBUpdate::readFileVersion ( )

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

References $fileVersion, $row, $version, and array.

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

194  {
195  //go through filecontent and search for last occurence of <#x>
196  reset($this->lastfilecontent);
197  $regs = array();
198  foreach ($this->lastfilecontent as $row)
199  {
200  if (preg_match('/^<\#([0-9]+)>/', $row, $regs))
201  {
202  $version = $regs[1];
203  }
204  }
205 
206  $this->fileVersion = (integer) $version;
207  return $this->fileVersion;
208  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readHotfixFileVersion()

ilDBUpdate::readHotfixFileVersion (   $a_file_content)

Set current hotfix version.

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

References $row, $version, and array.

Referenced by readHotfixInfo().

590  {
591  //go through filecontent and search for last occurence of <#x>
592  reset($a_file_content);
593  $regs = array();
594  foreach ($a_file_content as $row)
595  {
596  if (preg_match("/^<#([0-9]+)>/", $row, $regs))
597  {
598  $version = $regs[1];
599  }
600  }
601 
602  return (integer) $version;
603  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ readHotfixInfo()

ilDBUpdate::readHotfixInfo (   $a_force = false)

Get status of hotfix file.

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

References file, ILIAS_VERSION_NUMERIC, and readHotfixFileVersion().

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

609  {
610  if ($this->hotfix_info_read && !$a_force)
611  {
612  return;
613  }
614  include_once './Services/Administration/classes/class.ilSetting.php';
615  $this->hotfix_setting = new ilSetting("common", true);
616  $ilias_version = ILIAS_VERSION_NUMERIC;
617  $version_array = explode(".", $ilias_version);
618  $this->hotfix_version[0] = $version_array[0];
619  $this->hotfix_version[1] = $version_array[1];
620  $hotfix_file = $this->PATH."setup/sql/".$this->hotfix_version[0]."_".$this->hotfix_version[1]."_hotfixes.php";
621  if (is_file($hotfix_file))
622  {
623  $this->hotfix_content = @file($hotfix_file);
624  $this->hotfix_current_version = (int) $this->hotfix_setting->get("db_hotfixes_".
625  $this->hotfix_version[0]."_".$this->hotfix_version[1]);
626  $this->hotfix_file_version = $this->readHotfixFileVersion($this->hotfix_content);
627  }
628  $this->hotfix_info_read = true;
629  }
ILIAS Setting Class.
const ILIAS_VERSION_NUMERIC
Reload workbook from saved file
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 124 of file class.ilDBUpdate.php.

References array, and file.

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

125  {
126  if (!file_exists($this->LAST_UPDATE_FILE))
127  {
128  $this->error = "no_last_update_file";
129  $this->lastfilecontent = array();
130  return false;
131  }
132 
133  $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
134  return true;
135  }
Reload workbook from saved file
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setCurrentVersion()

ilDBUpdate::setCurrentVersion (   $a_version)

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

Referenced by applyUpdateNr().

146  {
147  include_once './Services/Administration/classes/class.ilSetting.php';
148  $set = new ilSetting("common", true);
149  $set->set("db_version", $a_version);
150  $this->currentVersion = $a_version;
151 
152  return true;
153  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ setCustomUpdatesCurrentVersion()

ilDBUpdate::setCustomUpdatesCurrentVersion (   $a_version)

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

References readCustomUpdatesInfo().

Referenced by applyUpdateNr().

705  {
706  $this->readCustomUpdatesInfo();
707  $this->custom_updates_setting->set('db_version_custom', $a_version);
708  $this->custom_updates_current_version = $a_version;
709  return true;
710  }
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 568 of file class.ilDBUpdate.php.

References readHotfixInfo().

Referenced by applyUpdateNr().

569  {
570  $this->readHotfixInfo();
571  $this->hotfix_setting->set("db_hotfixes_".
572  $this->hotfix_version[0]."_".$this->hotfix_version[1], $a_version);
573  $this->hotfix_current_version = $a_version;
574  return true;
575  }
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 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_update_running", $a_nr);
165  $this->db_update_running = $a_nr;
166  }
ILIAS Setting Class.
+ 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 17 of file class.ilDBUpdate.php.

◆ $fileVersion

ilDBUpdate::$fileVersion

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

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


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