Skip to content

Commit

Permalink
MDL-61351 core: added \core\session\manager\get_handler_class()
Browse files Browse the repository at this point in the history
* This is needed e.g. by the shibboleth logout handler to check which
type of sessions are used.
  • Loading branch information
t-schroeder authored and mdjnelson committed Jul 17, 2018
1 parent 4beca90 commit 81f55e4
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions lib/classes/session/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,34 @@ public static function get_performance_info() {
}

/**
* Create handler instance.
* Get fully qualified name of session handler class.
*
* @return string The name of the handler class
*/
protected static function load_handler() {
public static function get_handler_class() {
global $CFG, $DB;

if (self::$handler) {
return;
}

// Find out which handler to use.
if (PHPUNIT_TEST) {
$class = '\core\session\file';

return '\core\session\file';
} else if (!empty($CFG->session_handler_class)) {
$class = $CFG->session_handler_class;

return $CFG->session_handler_class;
} else if (!empty($CFG->dbsessions) and $DB->session_lock_supported()) {
$class = '\core\session\database';
return '\core\session\database';
}

} else {
$class = '\core\session\file';
return '\core\session\file';
}

/**
* Create handler instance.
*/
protected static function load_handler() {
if (self::$handler) {
return;
}

// Find out which handler to use.
$class = self::get_handler_class();
self::$handler = new $class();
}

Expand Down

0 comments on commit 81f55e4

Please sign in to comment.