MDL-81480 core: Sets user-level session storage functions

Also added @runInSeparateProcess on each session Redis cluster test to let the test run
in a separate process to avoid the error "the headers are not already sent" by PHPUnit.
This commit is contained in:
meirzamoodle 2024-04-10 13:49:55 +07:00
parent b621a7e4b3
commit c9cb89323c
3 changed files with 8 additions and 0 deletions

View File

@ -511,6 +511,7 @@ $string['privatefilesupload'] = 'Uploading directly to user private files area i
$string['processingstops'] = 'Processing stops here. Remaining records ignored.';
$string['querystringcannotbeempty'] = 'The query string cannot be empty.';
$string['redirecterrordetected'] = 'Unsupported redirect detected, script execution terminated';
$string['redissessionhandlerproblem'] = 'Setting up of redis session failed. Please notify the server administrator.';
$string['refoundto'] = 'Can be refunded to {$a}';
$string['refoundtoorigi'] = 'Refunded to original amount: {$a}';
$string['registrationdisabled'] = 'Registration is disabled on this site';

View File

@ -213,6 +213,11 @@ class redis extends handler implements SessionHandlerInterface {
throw new exception('sessionhandlerproblem', 'error', '', null, 'redis extension version must be at least 2.0');
}
$result = session_set_save_handler($this);
if (!$result) {
throw new exception('redissessionhandlerproblem', 'error');
}
$encrypt = (bool) ($this->sslopts ?? false);
// Set Redis server(s).
$trimmedservers = [];

View File

@ -68,6 +68,7 @@ class session_redis_cluster_test extends \advanced_testcase {
*
* It covers the behavior of session read and write operations under different compression configurations.
*
* @runInSeparateProcess
* @covers ::read
* @covers ::write
*/
@ -85,6 +86,7 @@ class session_redis_cluster_test extends \advanced_testcase {
* It sets up the environment to simulate multiple failed connection attempts and
* checks if the expected exception message is received.
*
* @runInSeparateProcess
* @covers ::init
*/
public function test_exception_when_connection_attempts_exceeded(): void {