Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Singleton class that handles checking for available updates. More...
Public Member Functions | |
cron () | |
The method being run via cron.php. | |
enabled () | |
Is checking for available updates enabled? | |
fetch () | |
Fetches the available update status from the remote site. | |
get_last_timefetched () | |
Returns the timestamp of the last execution of fetch(). | |
get_update_info ($component, array $options=array()) | |
Returns the available update information for the given component. | |
Static Public Member Functions | |
static | instance () |
Factory method for this class. | |
static | reset_caches ($phpunitreset=false) |
Reset any caches. | |
Protected Member Functions | |
__construct () | |
Direct initiation not allowed, use the factory method self::instance(). | |
__clone () | |
Sorry, this is singleton. | |
compare_responses (array $old, array $new) | |
Compares two raw $recentresponse records and returns the list of changed updates. | |
cron_autocheck_enabled () | |
Decide if the autocheck feature is disabled in the server setting. | |
cron_current_timestamp () | |
Returns the current timestamp. | |
cron_execute () | |
Fetch available updates info and eventually send notification to site admins. | |
cron_execution_offset () | |
Returns the cron execution offset for this site. | |
cron_has_fresh_fetch ($now) | |
Decide if the recently fetched data are still fresh enough. | |
cron_has_outdated_fetch ($now) | |
Decide if the fetch is outadated or even missing. | |
cron_mtrace ($msg, $eol=PHP_EOL) | |
Output cron debugging info. | |
cron_notifications (array $changes) | |
Given the list of changes in available updates, pick those to send to site admins. | |
cron_notify (array $notifications) | |
Sends the given notifications to site admins via messaging API. | |
decode_response ($response) | |
Decodes the raw string response from the update notifications provider. | |
get_response () | |
Makes cURL request to get data from the remote site. | |
is_same_release ($remote, $local=null) | |
Compare two release labels and decide if they are the same. | |
load_current_environment ($forcereload=false) | |
Sets the properties currentversion, currentrelease, currentbranch and currentplugins. | |
prepare_request_options () | |
Returns the list of cURL options to use when fetching available updates data. | |
prepare_request_params () | |
Returns the list of HTTP params to be sent to the updates provider URL. | |
prepare_request_url () | |
Returns the URL to send update requests to. | |
restore_response ($forcereload=false) | |
Loads the most recent raw response record we have fetched. | |
store_response ($response) | |
Stores the valid fetched response for later usage. | |
validate_response ($response) | |
Makes sure the response is valid, has correct API format etc. | |
Static Protected Attributes | |
static core update checker | $singletoninstance |
holds the singleton instance | |
Singleton class that handles checking for available updates.
|
protected |
Compares two raw $recentresponse records and returns the list of changed updates.
This method is used to populate potential update info to be sent to site admins.
array | $old | |
array | $new |
checker_exception |
array | parts of $new['updates'] that have changed |
|
protected |
Decide if the autocheck feature is disabled in the server setting.
bool | true if autocheck enabled, false if disabled |
|
protected |
Returns the current timestamp.
int | the timestamp |
|
protected |
Returns the cron execution offset for this site.
The main self::cron() is supposed to run every night in some random time between 01:00 and 06:00 AM (local time). The exact moment is defined by so called execution offset, that is the amount of time after 01:00 AM. The offset value is initially generated randomly and then used consistently at the site. This way, the regular checks against the download.moodle.org server are spread in time.
int | the offset number of seconds from range 1 sec to 5 hours |
|
protected |
Decide if the recently fetched data are still fresh enough.
int | $now | current timestamp |
bool | true if no need to re-fetch, false otherwise |
|
protected |
Decide if the fetch is outadated or even missing.
int | $now | current timestamp |
bool | false if no need to re-fetch, true otherwise |
|
protected |
Output cron debugging info.
string | $msg | output message |
string | $eol | end of line |
|
protected |
Given the list of changes in available updates, pick those to send to site admins.
array | $changes | as returned by self::compare_responses() |
array | of core\update\info objects to send to site admins |
|
protected |
Sends the given notifications to site admins via messaging API.
array | $notifications | array of core\update\info objects to send |
|
protected |
Decodes the raw string response from the update notifications provider.
string | $response | as returned by self::get_response() |
array | decoded response structure |
core\update\checker::enabled | ( | ) |
Is checking for available updates enabled?
The feature is enabled unless it is prohibited via config.php. If enabled, the button for manual checking for available updates is displayed at admin screens. To perform scheduled checks for updates automatically, the admin setting $CFG->updateautocheck has to be enabled.
bool |
core\update\checker::fetch | ( | ) |
Fetches the available update status from the remote site.
checker_exception |
core\update\checker::get_last_timefetched | ( | ) |
Returns the timestamp of the last execution of fetch().
int|null | null if it has never been executed or we don't known |
|
protected |
Makes cURL request to get data from the remote site.
string | raw request result |
checker_exception |
core\update\checker::get_update_info | ( | $component, | |
array | $options = array() ) |
Returns the available update information for the given component.
This method returns null if the most recent response does not contain any information about it. The returned structure is an array of available updates for the given component. Each update info is an object with at least one property called 'version'. Other possible properties are 'release', 'maturity', 'url' and 'downloadurl'.
For the 'core' component, the method returns real updates only (those with higher version). For all other components, the list of all known remote updates is returned and the caller (usually the core_plugin_manager) is supposed to make the actual comparison of versions.
string | $component | frankenstyle |
array | $options | with supported keys 'minmaturity' and/or 'notifybuilds' |
null|array | null or array of core\update\info objects |
|
static |
Factory method for this class.
core\update\checker | the singleton instance |
|
protected |
Compare two release labels and decide if they are the same.
string | $remote | release info of the available update |
null | string | $local | release info of the local code, defaults to $release defined in version.php |
boolean | true if the releases declare the same minor+major version |
|
protected |
Sets the properties currentversion, currentrelease, currentbranch and currentplugins.
bool | $forcereload |
|
protected |
Returns the list of cURL options to use when fetching available updates data.
array | of (string)param => (string)value |
|
protected |
Returns the list of HTTP params to be sent to the updates provider URL.
array | of (string)param => (string)value |
|
protected |
Returns the URL to send update requests to.
During the development or testing, you can set $CFG->alternativeupdateproviderurl to a custom URL that will be used. Otherwise the standard URL will be returned.
string | URL |
|
static |
Reset any caches.
bool | $phpunitreset |
|
protected |
Loads the most recent raw response record we have fetched.
After this method is called, $this->recentresponse is set to an array. If the array is empty, then either no data have been fetched yet or the fetched data do not have expected format (and thence they are ignored and a debugging message is displayed).
This implementation uses the config_plugins table as the permanent storage.
bool | $forcereload | reload even if it was already loaded |
|
protected |
Stores the valid fetched response for later usage.
This implementation uses the config_plugins table as the permanent storage.
string | $response | raw valid data returned by self::get_response() |
|
protected |
Makes sure the response is valid, has correct API format etc.
string | $response | raw response as returned by the self::get_response() |
checker_exception |