Skip to content

Commit

Permalink
MDL-63329 core: Remove memcache session support
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Sep 12, 2018
1 parent 175b370 commit 89aff0d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 291 deletions.
12 changes: 2 additions & 10 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,8 @@
// igbinary support to make the setting to work. Also, if you change the serializer you have to flush the database!
// $CFG->session_redis_serializer_use_igbinary = false; // Optional, default is PHP builtin serializer.
//
// Memcache session handler (requires memcached server and memcache extension):
// $CFG->session_handler_class = '\core\session\memcache';
// $CFG->session_memcache_save_path = '127.0.0.1:11211';
// $CFG->session_memcache_acquire_lock_timeout = 120;
// ** NOTE: Memcache extension has less features than memcached and may be
// less reliable. Use memcached where possible or if you encounter
// session problems. **
//
// Please be aware that when selecting either Memcached or Memcache for sessions that it is advised to use a dedicated
// memcache server. The memcache and memcached extensions do not provide isolated environments for individual uses.
// Please be aware that when selecting Memcached for sessions that it is advised to use a dedicated
// memcache server. The memcached extension does not provide isolated environments for individual uses.
// Using the same server for other purposes (MUC for example) can lead to sessions being prematurely removed should
// the other uses of the server purge the cache.
//
Expand Down
205 changes: 0 additions & 205 deletions lib/classes/session/memcache.php

This file was deleted.

31 changes: 30 additions & 1 deletion lib/classes/session/memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct() {
if (empty($this->savepath)) {
$this->servers = array();
} else {
$this->servers = util::connection_string_to_memcache_servers($this->savepath);
$this->servers = self::connection_string_to_memcache_servers($this->savepath);
}

if (empty($CFG->session_memcached_prefix)) {
Expand Down Expand Up @@ -268,4 +268,33 @@ public function kill_session($sid) {
}
}

/**
* Convert a connection string to an array of servers.
*
* "abc:123, xyz:789" to
* [
* ['abc', '123'],
* ['xyz', '789'],
* ]
*
* @param string $str save_path value containing memcached connection string
* @return array[]
*/
protected static function connection_string_to_memcache_servers(string $str) : array {
$servers = [];
$parts = explode(',', $str);
foreach ($parts as $part) {
$part = trim($part);
$pos = strrpos($part, ':');
if ($pos !== false) {
$host = substr($part, 0, $pos);
$port = substr($part, ($pos + 1));
} else {
$host = $part;
$port = 11211;
}
$servers[] = [$host, $port];
}
return $servers;
}
}
75 changes: 0 additions & 75 deletions lib/classes/session/util.php

This file was deleted.

2 changes: 2 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ information provided here is intended especially for developers.
- I navigate to "PATH > ITEM" in site administration
- I navigate to course participants
- I navigate to "TAB1 > TAB2" in the course gradebook
* The core\session\util class has been removed. This contained one function only used by the memcached class which has
been moved there instead (connection_string_to_memcache_servers).

If some items are not available without Navigation block at all, one can use combination of:
- I add the "Navigation" block if not present
Expand Down

0 comments on commit 89aff0d

Please sign in to comment.