Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 641 lines (26 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

restore_controller:: (41 methods):
  __construct()
  destroy()
  finish_ui()
  process_ui_event()
  set_status()
  set_execution()
  calculate_checksum()
  is_checksum_correct()
  get_tempdir()
  get_restoreid()
  get_type()
  get_operation()
  get_courseid()
  get_format()
  get_interactive()
  get_mode()
  get_userid()
  get_target()
  is_samesite()
  get_status()
  get_execution()
  get_executiontime()
  get_plan()
  get_setting_value()
  debug_display_all_settings_values()
  get_info()
  execute_plan()
  is_executing()
  execute_precheck()
  get_results()
  precheck_executed()
  get_precheck_results()
  save_controller()
  load_controller()
  get_tempdir_name()
  convert()
  prepare_copy()
  get_copy()
  calculate_restoreid()
  load_plan()
  apply_defaults()

restore_controller_exception:: (1 method):
  __construct()


Class: restore_controller  - X-Ref

Class implementing the controller of any restore process

This final class is in charge of controlling all the restore architecture, for any
type of backup.

TODO: Finish phpdocs
__construct($tempdir, $courseid, $interactive, $mode, $userid, $target,\core\progress\base $progress = null, $releasesession = backup::RELEASESESSION_NO, ?\stdClass $copydata = null)   X-Ref
Constructor.

If you specify a progress monitor, this will be used to report progress
while loading the plan, as well as for future use. (You can change it
for a different one later using set_progress.)

param: string $tempdir Directory under $CFG->backuptempdir awaiting restore
param: int $courseid Course id where restore is going to happen
param: bool $interactive backup::INTERACTIVE_YES[true] or backup::INTERACTIVE_NO[false]
param: int $mode backup::MODE_[ GENERAL | HUB | IMPORT | SAMESITE ]
param: int $userid
param: int $target backup::TARGET_[ NEW_COURSE | CURRENT_ADDING | CURRENT_DELETING | EXISTING_ADDING | EXISTING_DELETING ]
param: \core\progress\base $progress Optional progress monitor
param: \stdClass $copydata Course copy data, required when in MODE_COPY
param: bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO

destroy()   X-Ref
Clean structures used by the restore_controller

This method clean various structures used by the restore_controller,
destroying them in an ordered way, so their memory will be gc properly
by PHP (mainly circular references).

Note that, while it's not mandatory to execute this method, it's highly
recommended to do so, specially in scripts performing multiple operations
(like the automated backups) or the system will run out of memory after
a few dozens of backups)

finish_ui()   X-Ref
No description

process_ui_event()   X-Ref
No description

set_status($status)   X-Ref
No description

set_execution($execution, $executiontime = 0)   X-Ref
No description

calculate_checksum()   X-Ref
No description

is_checksum_correct($checksum)   X-Ref
No description

get_tempdir()   X-Ref
No description

get_restoreid()   X-Ref
No description

get_type()   X-Ref
No description

get_operation()   X-Ref
No description

get_courseid()   X-Ref
No description

get_format()   X-Ref
No description

get_interactive()   X-Ref
No description

get_mode()   X-Ref
No description

get_userid()   X-Ref
No description

get_target()   X-Ref
No description

is_samesite()   X-Ref
No description

get_status()   X-Ref
No description

get_execution()   X-Ref
No description

get_executiontime()   X-Ref
No description

get_plan()   X-Ref
Returns the restore plan

return: restore_plan

get_setting_value($name, $default = false)   X-Ref
Gets the value for the requested setting

param: string $name
param: bool $default
return: mixed

debug_display_all_settings_values()   X-Ref
For debug only. Get a simple test display of all the settings.

return: string

get_info()   X-Ref
No description

execute_plan()   X-Ref
No description

is_executing()   X-Ref
Checks whether restore is currently executing. Certain parts of code that
is called during restore, but not directly part of the restore system, may
need to behave differently during restore (e.g. do not bother resetting a
cache because we know it will be reset at end of operation).

return: bool True if any restore is currently executing

execute_precheck($droptemptablesafter = false)   X-Ref
Execute the restore prechecks to detect any problem before proceed with restore

This function checks various parts of the restore (versions, users, roles...)
returning true if everything was ok or false if any warning/error was detected.
Any warning/error is returned by the get_precheck_results() method.
Note: if any problem is found it will, automatically, drop all the restore temp
tables as far as the next step is to inform about the warning/errors. If no problem
is found, then default behaviour is to keep the temp tables so, in the same request
restore will be executed, saving a lot of checks to be executed again.
Note: If for any reason (UI to show after prechecks...) you want to force temp tables
to be dropped always, you can pass true to the $droptemptablesafter parameter

get_results()   X-Ref
No description

precheck_executed()   X-Ref
Returns true if the prechecks have been executed

return: bool

get_precheck_results()   X-Ref
No description

save_controller($includeobj = true, $cleanobj = false)   X-Ref
Save controller information

param: bool $includeobj to decide if the object itself must be updated (true) or no (false)
param: bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)

load_controller($restoreid)   X-Ref
No description

get_tempdir_name($courseid = 0, $userid = 0)   X-Ref
class method to provide pseudo random unique "correct" tempdir names


convert()   X-Ref
Converts from current format to backup::MOODLE format


prepare_copy()   X-Ref
Do the necessary copy preparation actions.
This method should only be called once the backup of a copy operation is completed.


get_copy()   X-Ref
Get the course copy data.

return: \stdClass

calculate_restoreid()   X-Ref
No description

load_plan()   X-Ref
No description

apply_defaults()   X-Ref
Apply defaults from the global admin settings


Class: restore_controller_exception  - X-Ref

__construct($errorcode, $a=NULL, $debuginfo=null)   X-Ref
No description