MDL-85316 admin: Add environment check for AWS Aurora database

This commit is contained in:
meirzamoodle
2025-06-11 10:16:21 +07:00
parent ffb6475f6a
commit 8bb9fe14ca
5 changed files with 60 additions and 1 deletions
+6
View File
@@ -4716,6 +4716,7 @@
<VENDOR name="mysql" version="8.4" />
<VENDOR name="postgres" version="14" />
<VENDOR name="mssql" version="14.0" />
<VENDOR name="auroramysql" version="8.0" />
</DATABASE>
<PHP version="8.2.0" level="required">
</PHP>
@@ -4895,6 +4896,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_async_backup" level="recommended">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_aurora_version" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="5.1" requires="4.2.3">
@@ -4908,6 +4911,7 @@
<VENDOR name="mysql" version="8.4" />
<VENDOR name="postgres" version="14" />
<VENDOR name="mssql" version="14.0" />
<VENDOR name="auroramysql" version="8.0" />
</DATABASE>
<PHP version="8.2.0" level="required">
</PHP>
@@ -5092,6 +5096,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_async_backup" level="recommended">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_aurora_version" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
+1
View File
@@ -621,6 +621,7 @@ $string['enroladminnewcourse_help'] = 'When an admin adds a new course, should t
$string['enrolinstancedefaults'] = 'Enrolment instance defaults';
$string['enrolinstancedefaults_desc'] = 'Default enrolment settings in new courses.';
$string['enrolmultipleusers'] = 'Enrol the users';
$string['ensureauroraversion'] = 'Your site is running on Amazon Aurora database engine. Please ensure that the MySQL version in Amazon Aurora is compatible with the Moodle version you are installing or upgrading to. You can check the compatibility in the <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/AuroraMySQL.Updates.30Updates.html" target="_blank">Database engine updates for Amazon Aurora MySQL version 3</a>.';
$string['environment'] = 'Environment';
$string['environmenterrortodo'] = 'You must solve all the environmental problems (errors) found above before proceeding to install this Moodle version!';
$string['environmenterrorupgrade'] = 'Warning: you should solve all the environmental problems (errors) found above before proceeding to upgrade this Moodle version! Upgrading without fixing these requirements could cause problems such as data loss. Are you sure you want to continue with the upgrade?';
@@ -68,7 +68,7 @@ class auroramysql_native_moodle_database extends mysqli_native_moodle_database {
* @return string The db vendor name, usually the same as db family name.
*/
public function get_dbvendor(): ?string {
return 'mysql';
return 'auroramysql';
}
/**
+32
View File
@@ -1731,4 +1731,36 @@ calendar,core_calendar|/calendar/view.php?view=month',
$this->assertEquals('/page2', get_user_preferences('user_home_page_preference', null, $user1->id));
$this->assertEquals(HOMEPAGE_MY, get_user_preferences('user_home_page_preference', null, $user2->id));
}
/**
* Test the check_aurora_version check when the Moodle instance is not using Amazon Aurora as a database architecture.
*
* @covers ::check_aurora_version
*/
public function test_check_aurora_version_is_not_used(): void {
global $CFG;
$this->resetAfterTest();
$CFG->dbtype = 'pgsql';
$result = new environment_results('custom_checks');
$this->assertNull(check_aurora_version($result));
}
/**
* Test the check_aurora_version check when the Moodle instance is using Amazon Aurora as a database architecture.
*
* @covers ::check_aurora_version
*/
public function test_check_aurora_version_is_used(): void {
global $CFG;
$this->resetAfterTest();
$CFG->dbtype = 'auroramysql';
$result = new environment_results('custom_checks');
$this->assertInstanceOf(environment_results::class, check_aurora_version($result));
$this->assertEquals('Aurora compatibility', $result->getInfo());
$this->assertFalse($result->getStatus());
}
}
+20
View File
@@ -2798,3 +2798,23 @@ function check_async_backup(environment_results $result): ?environment_results {
return null;
}
/**
* Checks if the current database vendor is Aurora MySQL.
*
* If the database vendor is 'auroramysql', this function sets additional information.
*
* @param environment_results $result The environment results object to update.
* @return environment_results|null The updated environment results object if Aurora is detected, or null otherwise.
*/
function check_aurora_version(environment_results $result): ?environment_results {
global $CFG;
if ($CFG->dbtype === 'auroramysql') {
$result->setInfo('Aurora compatibility');
$result->setFeedbackStr('ensureauroraversion');
return $result;
}
return null;
}