Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | List of all members
backup_general_helper Class Reference

Non instantiable helper class providing general helper methods for backup/restore. More...

Inheritance diagram for backup_general_helper:
backup_helper

Static Public Member Functions

static array_checksum_recursive ($arr)
 Calculate one checksum for any array/object. More...
 
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. More...
 
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. More...
 
static delete_backup_dir ($backupid, core\progress\base $progress=null)
 Given one backupid, delete completely its temp dir. More...
 
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. More...
 
static delete_old_backup_dirs ($deletefrom, core\progress\base $progress=null)
 Delete all the temp dirs older than the time specified. More...
 
static detect_backup_format ($tempdir)
 Detects the format of the given unpacked backup directory. More...
 
static get_backup_information ($tempdir)
 Load and format all the needed information from moodle_backup.xml. More...
 
static get_backup_information_from_mbz ($filepath, file_progress $progress=null)
 Load and format all the needed information from a backup file. More...
 
static get_blocks_from_path ($path)
 Load all the blocks information needed for a given path within moodle2 backup. More...
 
static get_inforef_itemnames ()
 This function returns one array of itemnames that are being handled by inforef.xml files. More...
 
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. More...
 
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. More...
 

Detailed Description

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

Member Function Documentation

◆ array_checksum_recursive()

static backup_general_helper::array_checksum_recursive (   $arr)
static

Calculate one checksum for any array/object.

Works recursively

◆ backup_is_samesite()

static backup_general_helper::backup_is_samesite (   $info)
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.

◆ clear_backup_dir()

static backup_helper::clear_backup_dir (   $backupid,
core\progress\base  $progress = null 
)
staticinherited

Given one backupid, ensure its temp dir is completely empty.

If supplied, progress object should be ready to receive indeterminate progress reports.

Parameters
string$backupidBackup id
core\progress\base$progressOptional progress reporting object

◆ delete_backup_dir()

static backup_helper::delete_backup_dir (   $backupid,
core\progress\base  $progress = null 
)
staticinherited

Given one backupid, delete completely its temp dir.

If supplied, progress object should be ready to receive indeterminate progress reports.

Parameters
string$backupidBackup id
core\progress\base$progressOptional progress reporting object

◆ delete_dir_contents()

static backup_helper::delete_dir_contents (   $dir,
  $excludeddir = '',
core\progress\base  $progress = null 
)
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.

Parameters
string$dirDirectory to delete
string$excludedirExclude this directory
core\progress\base$progressOptional progress reporting object

◆ delete_old_backup_dirs()

static backup_helper::delete_old_backup_dirs (   $deletefrom,
core\progress\base  $progress = null 
)
staticinherited

Delete all the temp dirs older than the time specified.

If supplied, progress object should be ready to receive indeterminate progress reports.

Parameters
int$deletefromTime to delete from
core\progress\base$progressOptional progress reporting object

◆ detect_backup_format()

static backup_general_helper::detect_backup_format (   $tempdir)
static

Detects the format of the given unpacked backup directory.

Parameters
string$tempdirthe name of the backup directory
Return values
stringone of backup::FORMAT_xxx constants

◆ get_backup_information()

static backup_general_helper::get_backup_information (   $tempdir)
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

◆ get_backup_information_from_mbz()

static backup_general_helper::get_backup_information_from_mbz (   $filepath,
file_progress  $progress = null 
)
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.

Parameters
string$filepathabsolute path to the MBZ file.
file_progress$progressProgress updates
Return values
stdClasscontaining information.
Since
Moodle 2.4

◆ get_blocks_from_path()

static backup_general_helper::get_blocks_from_path (   $path)
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

◆ get_inforef_itemnames()

static backup_helper::get_inforef_itemnames ( )
staticinherited

This function returns one array of itemnames that are being handled by inforef.xml files.

Used both by backup and restore

◆ is_sqlparam()

static backup_helper::is_sqlparam (   $value)
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

◆ store_backup_file()

static backup_helper::store_backup_file (   $backupid,
  $filepath,
core\progress\base  $progress = null 
)
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).

Parameters
int$backupid
string$filepathzip file containing the backup
core\progress\base$progressOptional progress monitor
Return values
stored_fileif created, null otherwise
Exceptions
moodle_exceptionin case of any problems

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