Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
upgrade

Classes

class  core_upgrade_time
 Static class monitors performance of upgrade steps. More...
 
class  downgrade_exception
 Exception indicating downgrade error during upgrade. More...
 
class  plugin_defective_exception
 
class  plugin_incompatible_exception
 Exception thrown when attempting to install a plugin that declares incompatibility with moodle version. More...
 
class  plugin_misplaced_exception
 Misplaced plugin exception. More...
 
class  upgrade_exception
 Exception indicating unknown error during upgrade. More...
 
class  upgrade_requires_exception
 

Functions

 admin_mnet_method_get_docblock (ReflectionFunctionAbstract $function)
 Given some sort of reflection function/method object, return an array of docblock lines, where each line is an array of keywords/descriptions.
 
 admin_mnet_method_get_help (ReflectionFunctionAbstract $function)
 Given some sort of reflection function/method object, return just the help text.
 
 admin_mnet_method_profile (ReflectionFunctionAbstract $function)
 Given some sort of reflection function/method object, return a profile array, ready to be serialized and stored.
 
 check_admin_dir_usage (environment_results $result)
 Check whether the admin directory has been configured and warn if so.
 
 check_async_backup (environment_results $result)
 Check if asynchronous backups are enabled.
 
 check_database_storage_engine (environment_results $result)
 This function verifies that the database is not using an unsupported storage engine.
 
 check_database_tables_row_format (environment_results $result)
 This function verifies if the database has tables using innoDB Antelope row format.
 
 check_db_prefix_length (environment_results $result)
 This function checks that the database prefix ($CFG->prefix) is <= xmldb_table\PREFIX_MAX_LENGTH.
 
 check_igbinary322_version (environment_results $result)
 Check if the igbinary extension installed is buggy one.
 
 check_is_https (environment_results $result)
 Check if the site is being served using an ssl url.
 
 check_libcurl_version (environment_results $result)
 Check if recommended version of libcurl is installed or not.
 
 check_max_input_vars (environment_results $result)
 Environment check for the php setting max_input_vars.
 
 check_mod_assignment (environment_results $result)
 Check whether the mod_assignment is currently being used.
 
 check_mysql_file_format (environment_results $result)
 This function verfies that the database has tables using InnoDB Antelope row format.
 
 check_mysql_file_per_table (environment_results $result)
 This function verfies that the database has a setting of one file per table.
 
 check_mysql_incomplete_unicode_support (environment_results $result)
 This function checks the database to see if it is using incomplete unicode support.
 
 check_mysql_large_prefix (environment_results $result)
 This function verfies that the database has the setting of large prefix enabled.
 
 check_oracle_usage (environment_results $result)
 Check whether the Oracle database is currently being used and warn if so.
 
 check_sixtyfour_bits (environment_results $result)
 Check if the site is using 64 bits PHP.
 
 check_slasharguments (environment_results $result)
 Method used to check the usage of slasharguments config and display a warning message.
 
 check_tls_libraries (environment_results $result)
 Checks for up-to-date TLS libraries.
 
 check_unoconv_version (environment_results $result)
 Method used to check the installed unoconv version.
 
 check_upgrade_key ($upgradekeyhash)
 Assert the upgrade key is provided, if it is defined.
 
 check_xmlrpc_usage (environment_results $result)
 Check whether the XML-RPC protocol is enabled and warn if so.
 
 core_tables_exist ()
 Checks if the main tables have been installed yet or not.
 
 external_update_descriptions ($component)
 Web service discovery function used during install and upgrade.
 
 external_update_services ()
 Allow plugins and subsystems to add external functions to other plugins or built-in services.
 
 install_core ($version, $verbose)
 Install core moodle tables and initialize.
 
 log_update_descriptions ($component)
 Log_display description function used during install and upgrade.
 
 print_upgrade_part_end ($plugin, $installation, $verbose)
 Default end upgrade callback.
 
 print_upgrade_part_start ($plugin, $installation, $verbose)
 Default start upgrade callback.
 
 print_upgrade_separator ()
 
 upgrade_block_savepoint ($result, $version, $blockname, $allowabort=true)
 Blocks upgrade savepoint, marks end of blocks upgrade blocks It stores block version, resets upgrade timeout and abort upgrade if user cancels page loading.
 
 upgrade_component_updated (string $component, string $messageplug='', bool $coreinstall=false)
 After upgrading a module, block, or generic plugin, various parts of the system need to be informed.
 
 upgrade_core ($version, $verbose)
 Upgrade moodle core.
 
object upgrade_finished ($continueurl=null)
 Indicates upgrade is finished.
 
 upgrade_finished_handler ()
 Internal function - executed if upgrade interrupted.
 
 upgrade_handle_exception ($ex, $plugin=null)
 upgrade logging functions
 
object upgrade_init_javascript ()
 Sets up JS code required for all upgrade scripts.
 
 upgrade_install_plugins (array $installable, $confirmed, $heading='', $continue=null, $return=null)
 Helper procedure/macro for installing remote plugins at admin/index.php.
 
 upgrade_language_pack ($lang=null)
 Try to upgrade the given language pack (or current language)
 
 upgrade_log ($type, $plugin, $info, $details=null, $backtrace=null)
 Adds log entry into upgrade_log table.
 
 upgrade_main_savepoint ($result, $version, $allowabort=true)
 Upgrade savepoint, marks end of each upgrade block.
 
 upgrade_mod_savepoint ($result, $version, $modname, $allowabort=true)
 Module upgrade savepoint, marks end of module upgrade blocks It stores module version, resets upgrade timeout and abort upgrade if user cancels page loading.
 
 upgrade_noncore ($verbose)
 Upgrade/install other parts of moodle.
 
 upgrade_plugin_mnet_functions ($component)
 upgrades the mnet rpc definitions for the given component.
 
 upgrade_plugin_savepoint ($result, $version, $type, $plugin, $allowabort=true)
 Plugins upgrade savepoint, marks end of plugin upgrade blocks It stores plugin version, resets upgrade timeout and abort upgrade if user cancels page loading.
 
 upgrade_plugins ($type, $startcallback, $endcallback, $verbose)
 Upgrade plugins.
 
object upgrade_plugins_blocks ($startcallback, $endcallback, $verbose)
 This function finds all available blocks and install them into blocks table or do all the upgrade process if newer.
 
object upgrade_plugins_modules ($startcallback, $endcallback, $verbose)
 Find and check all modules and load them up or upgrade them if necessary.
 
 upgrade_set_timeout ($max_execution_time=300)
 Sets maximum expected time needed for upgrade task.
 
object upgrade_setup_debug ($starting)
 @global object
 
 upgrade_stale_php_files_present ()
 Detect if there are leftovers in PHP source files.
 
object upgrade_started ($preinstall=false)
 Marks start of upgrade, blocks any other access to site.
 
 upgrade_themes ()
 Build the current theme so that the user doesn't have to wait for it to build on the first page load after the install / upgrade.
 

Variables

const UPGRADE_LOG_ERROR 2
 UPGRADE_LOG_ERROR = 2.
 
const UPGRADE_LOG_NORMAL 0
 UPGRADE_LOG_NORMAL = 0.
 
const UPGRADE_LOG_NOTICE 1
 UPGRADE_LOG_NOTICE = 1.
 

Detailed Description

Function Documentation

◆ admin_mnet_method_get_docblock()

admin_mnet_method_get_docblock ( ReflectionFunctionAbstract $function)

Given some sort of reflection function/method object, return an array of docblock lines, where each line is an array of keywords/descriptions.

Parameters
ReflectionFunctionAbstract$functionreflection function/method object from which to extract information
Return values
arraydocblock converted in to an array

◆ admin_mnet_method_get_help()

admin_mnet_method_get_help ( ReflectionFunctionAbstract $function)

Given some sort of reflection function/method object, return just the help text.

Parameters
ReflectionFunctionAbstract$functionreflection function/method object from which to extract information
Return values
stringdocblock help text

◆ admin_mnet_method_profile()

admin_mnet_method_profile ( ReflectionFunctionAbstract $function)

Given some sort of reflection function/method object, return a profile array, ready to be serialized and stored.

Parameters
ReflectionFunctionAbstract$functionreflection function/method object from which to extract information
Return values
arrayassociative array with function/method information

◆ check_admin_dir_usage()

check_admin_dir_usage ( environment_results $result)

Check whether the admin directory has been configured and warn if so.

The admin directory has been deprecated since Moodle 4.0.

Parameters
environment_results$result
Return values
null|environment_results

◆ check_async_backup()

check_async_backup ( environment_results $result)

Check if asynchronous backups are enabled.

Parameters
environment_results$result
Return values
environment_results|null

◆ check_database_storage_engine()

check_database_storage_engine ( environment_results $result)

This function verifies that the database is not using an unsupported storage engine.

Parameters
environment_results$resultobject to update, if relevant
Return values
environment_results|nullupdated results object, or null if the storage engine is supported

◆ check_database_tables_row_format()

check_database_tables_row_format ( environment_results $result)

This function verifies if the database has tables using innoDB Antelope row format.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if no Antelope table has been found.

◆ check_db_prefix_length()

check_db_prefix_length ( environment_results $result)

This function checks that the database prefix ($CFG->prefix) is <= xmldb_table\PREFIX_MAX_LENGTH.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if the prefix check is passing ok.

◆ check_igbinary322_version()

check_igbinary322_version ( environment_results $result)

Check if the igbinary extension installed is buggy one.

There are a few php-igbinary versions that are buggy and return any unserialised array with wrong index. This defeats key() and next() operations on them.

This library is used by MUC and also by memcached and redis when available.

Let's inform if there is some problem when:

  • php 7.2 is being used (php 7.3 and up are immune).
  • the igbinary extension is installed.
  • the version of the extension is between 3.2.2 and 3.2.4.
  • the buggy behaviour is reproduced.
Parameters
environment_results$resultobject to update, if relevant.
Return values
environment_results|nullupdated results or null.

◆ check_is_https()

check_is_https ( environment_results $result)

Check if the site is being served using an ssl url.

Note this does not really perform any request neither looks for proxies or other situations. Just looks to wwwroot and warn if it's not using https.

Parameters
environment_results$result$result
Return values
environment_results|nullupdated results object, or null if the site is https.

◆ check_libcurl_version()

check_libcurl_version ( environment_results $result)

Check if recommended version of libcurl is installed or not.

Parameters
environment_results$resultobject to update, if relevant.
Return values
environment_results|nullupdated results or null.

◆ check_max_input_vars()

check_max_input_vars ( environment_results $result)

Environment check for the php setting max_input_vars.

Parameters
environment_results$result
Return values
environment_results|null

◆ check_mod_assignment()

check_mod_assignment ( environment_results $result)

Check whether the mod_assignment is currently being used.

Parameters
environment_results$result
Return values
environment_results|null

◆ check_mysql_file_format()

check_mysql_file_format ( environment_results $result)

This function verfies that the database has tables using InnoDB Antelope row format.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if no Antelope table has been found.

◆ check_mysql_file_per_table()

check_mysql_file_per_table ( environment_results $result)

This function verfies that the database has a setting of one file per table.

This is required for 'utf8mb4'.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if innodb_file_per_table = 1.

◆ check_mysql_incomplete_unicode_support()

check_mysql_incomplete_unicode_support ( environment_results $result)

This function checks the database to see if it is using incomplete unicode support.

Parameters
environment_results$result$result
Return values
environment_results|nullupdated results object, or null if unicode is fully supported.

◆ check_mysql_large_prefix()

check_mysql_large_prefix ( environment_results $result)

This function verfies that the database has the setting of large prefix enabled.

This is required for 'utf8mb4'.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if innodb_large_prefix = 1.

◆ check_oracle_usage()

check_oracle_usage ( environment_results $result)

Check whether the Oracle database is currently being used and warn if so.

The Oracle database support will be removed in a future version (4.5) as it is no longer supported by PHP.

Parameters
environment_results$resultobject to update, if relevant
Return values
environment_results|nullupdated results or null if the current database is not Oracle.
See also
https://tracker.moodle.org/browse/MDL-80166 for further information.

◆ check_sixtyfour_bits()

check_sixtyfour_bits ( environment_results $result)

Check if the site is using 64 bits PHP.

Parameters
environment_results$result
Return values
environment_results|nullupdated results object, or null if the site is using 64 bits PHP.

◆ check_slasharguments()

check_slasharguments ( environment_results $result)

Method used to check the usage of slasharguments config and display a warning message.

Parameters
environment_results$resultobject to update, if relevant.
Return values
environment_results|nullupdated results or null if slasharguments is disabled.

◆ check_tls_libraries()

check_tls_libraries ( environment_results $result)

Checks for up-to-date TLS libraries.

NOTE: this is not currently used, see MDL-57262.

Parameters
environment_results$resultobject to update, if relevant.
Return values
environment_results|nullupdated results or null if unoconv path is not executable.

◆ check_unoconv_version()

check_unoconv_version ( environment_results $result)

Method used to check the installed unoconv version.

Parameters
environment_results$resultobject to update, if relevant.
Return values
environment_results|nullupdated results or null if unoconv path is not executable.

◆ check_upgrade_key()

check_upgrade_key ( $upgradekeyhash)

Assert the upgrade key is provided, if it is defined.

The upgrade key can be defined in the main config.php as $CFG->upgradekey. If it is defined there, then its value must be provided every time the site is being upgraded, regardless the administrator is logged in or not.

This is supposed to be used at certain places in /admin/index.php only.

Parameters
string | null$upgradekeyhashthe SHA-1 of the value provided by the user

◆ check_xmlrpc_usage()

check_xmlrpc_usage ( environment_results $result)

Check whether the XML-RPC protocol is enabled and warn if so.

The XML-RPC protocol will be removed in a future version (4.1) as it is no longer supported by PHP.

See MDL-70889 for further information.

Parameters
environment_results$result
Return values
null|environment_results

◆ core_tables_exist()

core_tables_exist ( )

Checks if the main tables have been installed yet or not.

Note: we can not use caches here because they might be stale, use with care!

Return values
bool

◆ external_update_descriptions()

external_update_descriptions ( $component)

Web service discovery function used during install and upgrade.

Parameters
string$componentname of component (moodle, etc.)
Return values
void

◆ external_update_services()

external_update_services ( )

Allow plugins and subsystems to add external functions to other plugins or built-in services.

This function is executed just after all the plugins have been updated.

◆ install_core()

install_core ( $version,
$verbose )

Install core moodle tables and initialize.

Parameters
float$versiontarget version
bool$verbose
Return values
void,maythrow exception

◆ log_update_descriptions()

log_update_descriptions ( $component)

Log_display description function used during install and upgrade.

Parameters
string$componentname of component (moodle, etc.)
Return values
void

◆ print_upgrade_part_end()

print_upgrade_part_end ( $plugin,
$installation,
$verbose )

Default end upgrade callback.

Parameters
string$plugin
bool$installationtrue if installation, false means upgrade

◆ print_upgrade_part_start()

print_upgrade_part_start ( $plugin,
$installation,
$verbose )

Default start upgrade callback.

Parameters
string$plugin
bool$installationtrue if installation, false means upgrade

◆ upgrade_block_savepoint()

upgrade_block_savepoint ( $result,
$version,
$blockname,
$allowabort = true )

Blocks upgrade savepoint, marks end of blocks upgrade blocks It stores block version, resets upgrade timeout and abort upgrade if user cancels page loading.

Parameters
bool$resultfalse if upgrade step failed, true if completed
string | float$versionmain version
string$blocknamename of block
bool$allowabortallow user to abort script execution here

◆ upgrade_component_updated()

upgrade_component_updated ( string $component,
string $messageplug = '',
bool $coreinstall = false )

After upgrading a module, block, or generic plugin, various parts of the system need to be informed.

Parameters
string$componentFrankenstyle component or 'moodle' for core
string$messageplugSet to the name of a message plugin if this is one
bool$coreinstallSet to true if this is the core install

◆ upgrade_core()

upgrade_core ( $version,
$verbose )

Upgrade moodle core.

Parameters
float$versiontarget version
bool$verbose
Return values
void,maythrow exception

◆ upgrade_finished()

object upgrade_finished ( $continueurl = null)

Indicates upgrade is finished.

This function may be called repeatedly.

@global object

◆ upgrade_install_plugins()

upgrade_install_plugins ( array $installable,
$confirmed,
$heading = '',
$continue = null,
$return = null )

Helper procedure/macro for installing remote plugins at admin/index.php.

Does not return, always redirects or exits.

Parameters
array$installablelist of core\update\remote_info
bool$confirmedfalse: display the validation screen, true: proceed installation
string$headingvalidation screen heading
moodle_url | string | null$continueURL to proceed with installation at the validation screen
moodle_url | string | null$returnURL to go back on cancelling at the validation screen

◆ upgrade_language_pack()

upgrade_language_pack ( $lang = null)

Try to upgrade the given language pack (or current language)

Parameters
string$langthe code of the language to update, defaults to the current language

◆ upgrade_log()

upgrade_log ( $type,
$plugin,
$info,
$details = null,
$backtrace = null )

Adds log entry into upgrade_log table.

Parameters
int$typeUPGRADE_LOG_NORMAL, UPGRADE_LOG_NOTICE or UPGRADE_LOG_ERROR
string$pluginfrankenstyle component name
string$infoshort description text of log entry
string$detailslong problem description
string$backtracestring used for errors only
Return values
void

◆ upgrade_main_savepoint()

upgrade_main_savepoint ( $result,
$version,
$allowabort = true )

Upgrade savepoint, marks end of each upgrade block.

It stores new main version, resets upgrade timeout and abort upgrade if user cancels page loading.

Please do not make large upgrade blocks with lots of operations, for example when adding tables keep only one table operation per block.

Parameters
bool$resultfalse if upgrade step failed, true if completed
stringor float $version main version
bool$allowabortallow user to abort script execution here
Return values
void

◆ upgrade_mod_savepoint()

upgrade_mod_savepoint ( $result,
$version,
$modname,
$allowabort = true )

Module upgrade savepoint, marks end of module upgrade blocks It stores module version, resets upgrade timeout and abort upgrade if user cancels page loading.

Parameters
bool$resultfalse if upgrade step failed, true if completed
string | float$versionmain version
string$modnamename of module
bool$allowabortallow user to abort script execution here

◆ upgrade_noncore()

upgrade_noncore ( $verbose)

Upgrade/install other parts of moodle.

Parameters
bool$verbose
Return values
void,maythrow exception

◆ upgrade_plugin_mnet_functions()

upgrade_plugin_mnet_functions ( $component)

upgrades the mnet rpc definitions for the given component.

this method doesn't return status, an exception will be thrown in the case of an error

Parameters
string$componentthe plugin to upgrade, eg auth_mnet

◆ upgrade_plugin_savepoint()

upgrade_plugin_savepoint ( $result,
$version,
$type,
$plugin,
$allowabort = true )

Plugins upgrade savepoint, marks end of plugin upgrade blocks It stores plugin version, resets upgrade timeout and abort upgrade if user cancels page loading.

Parameters
bool$resultfalse if upgrade step failed, true if completed
string | float$versionmain version
string$typeThe type of the plugin.
string$pluginThe name of the plugin.
bool$allowabortallow user to abort script execution here

◆ upgrade_plugins()

upgrade_plugins ( $type,
$startcallback,
$endcallback,
$verbose )

Upgrade plugins.

Parameters
string$typeThe type of plugins that should be updated (e.g. 'enrol', 'qtype') return void

◆ upgrade_plugins_blocks()

object upgrade_plugins_blocks ( $startcallback,
$endcallback,
$verbose )

This function finds all available blocks and install them into blocks table or do all the upgrade process if newer.

@global object

◆ upgrade_plugins_modules()

object upgrade_plugins_modules ( $startcallback,
$endcallback,
$verbose )

Find and check all modules and load them up or upgrade them if necessary.

@global object

◆ upgrade_set_timeout()

upgrade_set_timeout ( $max_execution_time = 300)

Sets maximum expected time needed for upgrade task.

Please always make sure that upgrade will not run longer!

The script may be automatically aborted if upgrade times out.

Parameters
int$max_execution_timein seconds (can not be less than 60 s)

◆ upgrade_stale_php_files_present()

upgrade_stale_php_files_present ( )

Detect if there are leftovers in PHP source files.

During main version upgrades administrators MUST move away old PHP source files and start from scratch (or better use git).

Return values
booltrue means borked upgrade, false means previous PHP files were properly removed

◆ upgrade_started()

object upgrade_started ( $preinstall = false)

Marks start of upgrade, blocks any other access to site.

The upgrade is finished at the end of script or after timeout.

@global object @global object