ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPluginDBUpdate Class Reference

Database Update class. More...

+ Inheritance diagram for ilPluginDBUpdate:
+ Collaboration diagram for ilPluginDBUpdate:

Public Member Functions

 __construct (\ilDBInterface $db, \ilPluginInfo $plugin)
 constructor MagicMethodsValidityInspection More...
 
 getFileForStep (int $a_version)
 FROM ilDBUpdate. More...
 
 getCurrentVersion ()
 Get current DB version. More...
 
 setCurrentVersion (int $a_version)
 Set current DB version. More...
 
 loadXMLInfo ()
 
 checkQuery (string $q)
 This is a very simple check. More...
 
 getDBUpdateScriptName ()
 
- Public Member Functions inherited from ilDBUpdate
 __construct (ilDBInterface $a_db_handler, ilIniFile $client_ini=null)
 
 getFileForStep (int $a_version)
 Get db update file name for db step. More...
 
 initStep (int $i)
 
 readDBUpdateFile ()
 
 readLastUpdateFile ()
 
 getCurrentVersion ()
 
 setCurrentVersion (int $a_version)
 
 setRunningStatus (int $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 (ilDBInterface $db, string $str)
 execute a query More...
 
 checkQuery (string $q)
 check query More...
 
 applyUpdate (int $a_break=0)
 Apply update. More...
 
 applyUpdateNr (int $nr, $hotfix=false, $custom_update=false)
 apply an update More...
 
 getDBVersionStatus ()
 
 getTables ()
 
 getTableStatus (string $table)
 
 getHotfixCurrentVersion ()
 Get current hotfix version. More...
 
 setHotfixCurrentVersion (int $a_version)
 Set current hotfix version. More...
 
 getHotfixFileVersion ()
 Get current hotfix version. More...
 
 readHotfixFileVersion (array $a_file_content)
 Set current hotfix version. More...
 
 readHotfixInfo (bool $a_force=false)
 Get status of hotfix file. More...
 
 hotfixAvailable ()
 Get status of hotfix file. More...
 
 applyHotfix ()
 Apply hotfix. More...
 
 getCustomUpdatesCurrentVersion ()
 
 setCustomUpdatesCurrentVersion (?int $a_version)
 
 getCustomUpdatesFileVersion ()
 
 readCustomUpdatesFileVersion (array $a_file_content)
 
 readCustomUpdatesInfo (bool $a_force=false)
 
 customUpdatesAvailable ()
 
 applyCustomUpdates ()
 
 getUpdateSteps (int $a_break=0)
 Get update steps as string (for presentation) More...
 
 getHotfixSteps ()
 Get hotfix steps. More...
 
 getUpdateStepNr (int $nr, bool $hotfix=false, bool $custom_update=false)
 Get single update step for presentation. More...
 

Protected Member Functions

 getTablePrefix ()
 

Protected Attributes

const PLUGIN_UPDATE_FILE = "/sql/dbupdate.php"
 
ilDBInterface $db
 
ilPluginInfo $plugin
 
- Protected Attributes inherited from ilDBUpdate
ilIniFile $client_ini = null
 
int $custom_updates_current_version = 0
 
int $custom_updates_file_version = null
 
bool $custom_updates_info_read = null
 
string $error
 
string $PATH = './'
 
ilDBInterface $db
 
string $current_file
 
string $LAST_UPDATE_FILE
 
array $filecontent
 
array $lastfilecontent
 
int $db_update_running
 
int $hotfix_current_version
 
ilSetting $hotfix_setting
 
array $hotfix_version
 
array $hotfix_content
 
int $hotfix_file_version
 
ilSetting $custom_updates_setting
 
array $custom_updates_content
 
Iterator $ctrl_structure_iterator
 

Additional Inherited Members

- Data Fields inherited from ilDBUpdate
string $DB_UPDATE_FILE
 
int $currentVersion = null
 
int $fileVersion = null
 
string $updateMsg
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilPluginDBUpdate::__construct ( \ilDBInterface  $db,
\ilPluginInfo  $plugin 
)

constructor MagicMethodsValidityInspection

Definition at line 39 of file class.ilPluginDBUpdate.php.

References $db, ilDBUpdate\$DB_UPDATE_FILE, $plugin, ilPluginInfo\getCurrentDBVersion(), getDBUpdateScriptName(), getFileForStep(), PATH, ilDBUpdate\readDBUpdateFile(), ilDBUpdate\readFileVersion(), and ilDBUpdate\readLastUpdateFile().

42  {
43  $this->client_ini = null;
44  $this->db = $db;
45  $this->plugin = $plugin;
46 
47  $this->currentVersion = $plugin->getCurrentDBVersion() ?? 0;
48 
49  $this->current_file = $this->getFileForStep(0 /* doesn't matter */);
50  $this->DB_UPDATE_FILE = $this->PATH . $this->getDBUpdateScriptName();
51  $this->LAST_UPDATE_FILE = $this->DB_UPDATE_FILE;
52 
53  $this->readDBUpdateFile();
54  $this->readLastUpdateFile();
55  $this->readFileVersion();
56 
57  $class_map = require ILIAS_ABSOLUTE_PATH . '/libs/composer/vendor/composer/autoload_classmap.php';
58  $this->ctrl_structure_iterator = new ilCtrlArrayIterator($class_map);
59  }
const PATH
Definition: proxy_ylocal.php:8
getFileForStep(int $a_version)
FROM ilDBUpdate.
Class ilCtrlArrayIterator.
string $DB_UPDATE_FILE
+ Here is the call graph for this function:

Member Function Documentation

◆ checkQuery()

ilPluginDBUpdate::checkQuery ( string  $q)

This is a very simple check.

Could be done better.

Definition at line 93 of file class.ilPluginDBUpdate.php.

References getTablePrefix().

93  : bool
94  {
95  if ((is_int(stripos($q, "create table")) || is_int(stripos($q, "alter table")) ||
96  is_int(stripos($q, "drop table")))
97  && !is_int(stripos($q, $this->getTablePrefix()))) {
98  return false;
99  }
100 
101  return true;
102  }
+ Here is the call graph for this function:

◆ getCurrentVersion()

ilPluginDBUpdate::getCurrentVersion ( )

Get current DB version.

Definition at line 72 of file class.ilPluginDBUpdate.php.

References ilDBUpdate\$currentVersion.

72  : int
73  {
74  return $this->currentVersion;
75  }

◆ getDBUpdateScriptName()

ilPluginDBUpdate::getDBUpdateScriptName ( )

Definition at line 104 of file class.ilPluginDBUpdate.php.

Referenced by __construct().

104  : string
105  {
106  return $this->plugin->getPath() . self::PLUGIN_UPDATE_FILE;
107  }
+ Here is the caller graph for this function:

◆ getFileForStep()

ilPluginDBUpdate::getFileForStep ( int  $a_version)

FROM ilDBUpdate.

Definition at line 64 of file class.ilPluginDBUpdate.php.

Referenced by __construct().

64  : string
65  {
66  return "dbupdate.php";
67  }
+ Here is the caller graph for this function:

◆ getTablePrefix()

ilPluginDBUpdate::getTablePrefix ( )
protected

Definition at line 109 of file class.ilPluginDBUpdate.php.

Referenced by checkQuery().

109  : string
110  {
111  $component = $this->plugin->getComponent();
112  $slot = $this->plugin->getPluginSlot();
113  return $component->getId() . "_" . $slot->getId() . "_" . $this->plugin->getId();
114  }
+ Here is the caller graph for this function:

◆ loadXMLInfo()

ilPluginDBUpdate::loadXMLInfo ( )

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

85  : bool
86  {
87  return true;
88  }

◆ setCurrentVersion()

ilPluginDBUpdate::setCurrentVersion ( int  $a_version)

Set current DB version.

Definition at line 80 of file class.ilPluginDBUpdate.php.

80  : void
81  {
82  $this->currentVersion = $a_version;
83  }

Field Documentation

◆ $db

ilDBInterface ilPluginDBUpdate::$db
protected

Definition at line 32 of file class.ilPluginDBUpdate.php.

Referenced by __construct().

◆ $plugin

ilPluginInfo ilPluginDBUpdate::$plugin
protected

Definition at line 33 of file class.ilPluginDBUpdate.php.

Referenced by __construct().

◆ PLUGIN_UPDATE_FILE

const ilPluginDBUpdate::PLUGIN_UPDATE_FILE = "/sql/dbupdate.php"
protected

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


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