MDL-80167 admin: Add environment check for Oracle database

This commit is contained in:
Huong Nguyen 2024-03-05 11:40:07 +07:00
parent 70f611116d
commit 6a19d3289b
4 changed files with 64 additions and 0 deletions

View File

@ -3923,6 +3923,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_xmlrpc_usage" level="optional">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="4.2" requires="3.11.8">
@ -4113,6 +4115,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mod_assignment" level="required">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="4.3" requires="3.11.8">
@ -4305,6 +4309,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_db_prefix_length" level="required">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="4.4" requires="4.1.2">
@ -4496,6 +4502,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_db_prefix_length" level="required">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>

View File

@ -986,6 +986,7 @@ $string['opensslrecommended'] = 'Installing the optional OpenSSL library is high
$string['opensslrequired'] = 'The OpenSSL PHP extension is now required by Moodle to provide stronger cryptographic services.';
$string['opentowebcrawlers'] = 'Open to search engines';
$string['optionalmaintenancemessage'] = 'Optional maintenance message';
$string['oracledatabaseinuse'] = 'We are changing Oracle DB support in Moodle LMS. Moodle version 4.5 will be the last version that supports Oracle as a database architecture. Further information can be found <a href="https://moodle.org/mod/forum/discuss.php?d=456122" target="_blank">here</a>';
$string['order1'] = 'First';
$string['order2'] = 'Second';
$string['order3'] = 'Third';

View File

@ -1390,6 +1390,38 @@ class upgradelib_test extends advanced_testcase {
}
}
/**
* Test the check_oracle_usage check when the Moodle instance is not using Oracle as a database architecture.
*
* @covers ::check_oracle_usage
*/
public function test_check_oracle_usage_is_not_used(): void {
global $CFG;
$this->resetAfterTest();
$CFG->dbtype = 'pgsql';
$result = new environment_results('custom_checks');
$this->assertNull(check_oracle_usage($result));
}
/**
* Test the check_oracle_usage check when the Moodle instance is using Oracle as a database architecture.
*
* @covers ::check_oracle_usage
*/
public function test_check_oracle_usage_is_used(): void {
global $CFG;
$this->resetAfterTest();
$CFG->dbtype = 'oci';
$result = new environment_results('custom_checks');
$this->assertInstanceOf(environment_results::class, check_oracle_usage($result));
$this->assertEquals('oracle_database_usage', $result->getInfo());
$this->assertFalse($result->getStatus());
}
/**
* Data provider of usermenu items.
*

View File

@ -2875,3 +2875,26 @@ function check_mod_assignment(environment_results $result): ?environment_results
return null;
}
/**
* 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.
*
* @param environment_results $result object to update, if relevant
* @return environment_results|null updated results or null if the current database is not Oracle.
*
* @see https://tracker.moodle.org/browse/MDL-80166 for further information.
*/
function check_oracle_usage(environment_results $result): ?environment_results {
global $CFG;
// Checking database type.
if ($CFG->dbtype === 'oci') {
$result->setInfo('oracle_database_usage');
$result->setFeedbackStr('oracledatabaseinuse');
return $result;
}
return null;
}