Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
|
Non instantiable helper class providing general helper methods for backup/restore. More...
Static Public Member Functions | |
static | array_checksum_recursive ($arr) |
Calculate one checksum for any array/object. | |
static | backup_is_samesite ($info) |
Given the information fetched from moodle_backup.xml file decide if we are restoring in the same site the backup was generated or no. | |
static | check_and_create_backup_dir ($backupid) |
Given one backupid, create all the needed dirs to have one backup temp dir available. | |
static | clear_backup_dir ($backupid, core\progress\base $progress=null) |
Given one backupid, ensure its temp dir is completely empty. | |
static | delete_backup_dir ($backupid, core\progress\base $progress=null) |
Given one backupid, delete completely its temp dir. | |
static | delete_dir_contents ($dir, $excludeddir='', core\progress\base $progress=null) |
Given one fullpath to directory, delete its contents recursively Copied originally from somewhere in the net. | |
static | delete_old_backup_dirs ($deletebefore, core\progress\base $progress=null) |
Delete all the temp dirs older than the time specified. | |
static | detect_backup_format ($tempdir) |
Detects the format of the given unpacked backup directory. | |
static | get_backup_information ($tempdir) |
Load and format all the needed information from moodle_backup.xml. | |
static | get_backup_information_from_mbz ($filepath, file_progress $progress=null) |
Load and format all the needed information from a backup file. | |
static | get_blocks_from_path ($path) |
Load all the blocks information needed for a given path within moodle2 backup. | |
static | get_inforef_itemnames () |
This function returns one array of itemnames that are being handled by inforef.xml files. | |
static | is_sqlparam ($value) |
This function simply marks one param to be considered as straight sql param, so it won't be searched in the structure tree nor converted at all. | |
static | log ($message, $level, $a, $depth, $display, $logger) |
This function will be invoked by any log() method in backup/restore, acting as a simple forwarder to the standard loggers but also, if the $display parameter is true, supporting translation via get_string() and sending to standard output. | |
static | store_backup_file ($backupid, $filepath, core\progress\base $progress=null) |
Given one backupid and the (FS) final generated file, perform its final storage into Moodle file storage. | |
Non instantiable helper class providing general helper methods for backup/restore.
This class contains various general helper static methods available for backup/restore
TODO: Finish phpdocs
|
static |
Calculate one checksum for any array/object.
Works recursively
|
static |
Given the information fetched from moodle_backup.xml file decide if we are restoring in the same site the backup was generated or no.
Behavior of various parts of restore are dependent of this.
Backups created natively in 2.0 and later declare the hashed site identifier. Backups created by conversion from a 1.9 backup do not declare such identifier, so there is a fallback to wwwroot comparison. See MDL-16614.
|
staticinherited |
Given one backupid, ensure its temp dir is completely empty.
If supplied, progress object should be ready to receive indeterminate progress reports.
string | $backupid | Backup id |
core\progress\base | $progress | Optional progress reporting object |
|
staticinherited |
Given one backupid, delete completely its temp dir.
If supplied, progress object should be ready to receive indeterminate progress reports.
string | $backupid | Backup id |
core\progress\base | $progress | Optional progress reporting object |
|
staticinherited |
Given one fullpath to directory, delete its contents recursively Copied originally from somewhere in the net.
TODO: Modernise this
If supplied, progress object should be ready to receive indeterminate progress reports.
string | $dir | Directory to delete |
string | $excludedir | Exclude this directory |
core\progress\base | $progress | Optional progress reporting object |
|
staticinherited |
Delete all the temp dirs older than the time specified.
If supplied, progress object should be ready to receive indeterminate progress reports.
int | $deletebefore | Delete files and directories older than this time |
core\progress\base | $progress | Optional progress reporting object |
|
static |
Detects the format of the given unpacked backup directory.
string | $tempdir | the name of the backup directory |
string | one of backup\FORMAT_xxx constants |
|
static |
Load and format all the needed information from moodle_backup.xml.
This function loads and process all the moodle_backup.xml information, composing a big information structure that will be the used by the plan builder in order to generate the appropiate tasks / steps / settings
|
static |
Load and format all the needed information from a backup file.
This will only extract the moodle_backup.xml file from an MBZ file and then call self::get_backup_information().
This can be a long-running (multi-minute) operation for large backups. Pass a $progress value to receive progress updates.
string | $filepath | absolute path to the MBZ file. |
file_progress | $progress | Progress updates |
stdClass | containing information. |
|
static |
Load all the blocks information needed for a given path within moodle2 backup.
This function, given one full path (course, activities/xxxx) will look for all the blocks existing in the backup file, returning one array used to build the proper restore plan by the @restore_plan_builder
|
staticinherited |
This function returns one array of itemnames that are being handled by inforef.xml files.
Used both by backup and restore
|
staticinherited |
This function simply marks one param to be considered as straight sql param, so it won't be searched in the structure tree nor converted at all.
Useful for better integration of definition of sources in structure and DB stuff
|
staticinherited |
Given one backupid and the (FS) final generated file, perform its final storage into Moodle file storage.
For stored files it returns the complete file_info object
Note: the $filepath is deleted if the backup file is created successfully
If you specify the progress monitor, this will start a new progress section to track progress in processing (in case this task takes a long time).
int | $backupid | |
string | $filepath | zip file containing the backup |
core\progress\base | $progress | Optional progress monitor |
stored_file | if created, null otherwise |
moodle_exception | in case of any problems |