From feb5468de796321a4354ec71f9b905b8a7f81ae3 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Fri, 14 Jun 2024 09:29:17 +0700 Subject: [PATCH 1/3] MDL-79809 environment: Add recommended custom check Add support for custom environment checks to have a recommended option in addition to required an optional. --- admin/renderer.php | 7 +++++-- lang/en/admin.php | 1 + lib/environmentlib.php | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/admin/renderer.php b/admin/renderer.php index 6141dfec8a6..990efa48719 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -2051,8 +2051,10 @@ class core_admin_renderer extends plugin_renderer_base { // We are checking installed & enabled things if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentrequirecustomcheck'; - } else { + } else if ($environment_result->getLevel() == 'optional') { $stringtouse = 'environmentrecommendcustomcheck'; + } else { + $stringtouse = 'environmentshouldfixcustomcheck'; } } else if ($environment_result->getPart() == 'php_setting') { @@ -2083,7 +2085,8 @@ class core_admin_renderer extends plugin_renderer_base { if ($status) { //Handle ok result (ok) $status = get_string('statusok'); } else { - if ($environment_result->getLevel() == 'optional') {//Handle check result (warning) + // Handle check result (warning). + if (in_array($environment_result->getLevel(), ['optional', 'recommended'])) { $status = get_string('check'); $warningline = true; } else { //Handle error result (error) diff --git a/lang/en/admin.php b/lang/en/admin.php index f7eb015f451..09829c0ea0c 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -636,6 +636,7 @@ $string['environmentrequirecustomcheck'] = 'this test must pass'; $string['environmentrequireinstall'] = 'must be installed and enabled'; $string['environmentrequireversion'] = 'version {$a->needed} is required and you are running {$a->current}'; $string['environmentsettingok'] = 'recommended setting detected'; +$string['environmentshouldfixcustomcheck'] = 'should be enabled for best results'; $string['environmentshouldfixsetting'] = 'PHP setting should be changed.'; $string['environmentxmlerror'] = 'Error reading environment data ({$a->error_code})'; $string['environmentmariadbwrongdbtype'] = 'Wrong $CFG->dbtype. You need to change it in your config.php file from \'mysqli\' to \'mariadb\'.'; diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 4d82c2ca49a..05e9d0be157 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -1251,7 +1251,7 @@ class environment_results { */ var $error_code; /** - * @var string required/optional + * @var string required/optional/recommended. */ var $level; /** @@ -1548,8 +1548,9 @@ function get_level($element) { $level = 'required'; if (isset($element['@']['level'])) { $level = $element['@']['level']; - if (!in_array($level, array('required', 'optional'))) { - debugging('The level of a check in the environment.xml file must be "required" or "optional".', DEBUG_DEVELOPER); + if (!in_array($level, ['required', 'optional', 'recommended'])) { + debugging('The level of a check in the environment.xml file must be "required", "optional" or "recommended".', + DEBUG_DEVELOPER); $level = 'required'; } } else { From 9ea30b852de82c129433e3c93784bfdb37556402 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Thu, 13 Jun 2024 15:39:41 +0700 Subject: [PATCH 2/3] MDL-79809 environment: Add missing Moodle 4.4 requirements --- admin/environment.xml | 2 ++ lang/en/admin.php | 3 +++ lib/upgradelib.php | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/admin/environment.xml b/admin/environment.xml index e031c7fc270..20fdcd27ad9 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -4504,6 +4504,8 @@ + + diff --git a/lang/en/admin.php b/lang/en/admin.php index 09829c0ea0c..9cf4b9d91b3 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -73,6 +73,9 @@ $string['alternativefullnameformat_desc'] = 'This defines how names are shown to $string['always'] = 'Always'; $string['appearance'] = 'Appearance'; $string['aspellpath'] = 'Path to aspell'; +$string['asyncbackupdisabled'] = 'Your site is currently configured to use synchronous backups. Asynchronous backups provide a better user experience. +Asynchronous backups will be enabled for all sites from Moodle LMS 4.5 LTS. +Synchronous backups will be removed from Moodle LMS the version after 4.5 LTS'; $string['authentication'] = 'Authentication'; $string['authpreventaccountcreation'] = 'Prevent account creation when authenticating'; $string['authpreventaccountcreation_help'] = 'When a user authenticates, an account on the site is automatically created if it doesn\'t yet exist. If an external database, such as LDAP, is used for authentication, but you wish to restrict access to the site to users with an existing account only, then this option should be enabled. New accounts will need to be created manually or via the upload users feature. Note that this setting doesn\'t apply to MNet authentication.'; diff --git a/lib/upgradelib.php b/lib/upgradelib.php index ca122bd8b3f..f6d286e41ee 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -2887,3 +2887,21 @@ function check_oracle_usage(environment_results $result): ?environment_results { return null; } + +/** + * Check if asynchronous backups are enabled. + * + * @param environment_results $result + * @return environment_results|null + */ +function check_async_backup(environment_results $result): ?environment_results { + global $CFG; + + if (!during_initial_install() && empty($CFG->enableasyncbackup)) { // Have to use $CFG as config table may not be available. + $result->setInfo('Asynchronous backups disabled'); + $result->setFeedbackStr('asyncbackupdisabled'); + return $result; + } + + return null; +} From ab1982b6005327cd59112ef6c6ad779f48863fdd Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Thu, 13 Jun 2024 14:39:24 +0700 Subject: [PATCH 3/3] MDL-79809 environment: Moodle 4.5 requirements --- admin/environment.xml | 195 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/admin/environment.xml b/admin/environment.xml index 20fdcd27ad9..2fd7533f84a 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -4508,4 +4508,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +