MediaWiki 1.22 - Session Storage

2019-08-30 17:55发布

问题:

I am trying to use MySQL as session storage for MediaWiki.

I've added:

$wgSessionHandler = 'session_mysql';

to "LocalSettings.php", but I can't find any session table in associated MySQL DB.

回答1:

If you set $wgSessionHandler = 'session_mysql';, you ask PHP to internally manage the sessions with a MySQL backend instead of the default file backend. In this case, you have to install and configure this MySQL backend yourself (by quickly searching I found https://github.com/repoforge/rpms/blob/master/specs/php-pecl-session_mysql/php-pecl-session_mysql.spec but this package seems quite old). In particular, you will have to choose the host, user, database and table to store your sessions.

Instead, for your request, I suggest using the MediaWiki session cache manager with the MySQL backend. This will do the same thing as the previous solution, but this is properly integrated in MediaWiki. To achieve this behaviour, write in your LocalSettings.php:

$wgSessionsInObjectCache = true; # MW internal session cache management
                                 # takes precedence over PHP management
$wgSessionCacheType = CACHE_DB; # See documentation for other backends
$wgObjectCacheSessionExpiry = 3600; # Default lifetime of the sessions

It seems it doesn’t work with SQLite, but it works well with MySQL. In this cache, you can inspect the table objectcache where there are keys named wikiID:session:sessionsID among other possible cached objects.



回答2:

For configuration changes that affects the database layout, you usually you need to run the update.php script:

php maintenance/update.php

If, for some reason, you are not able to access the command line, you should be able to achieve the same result by navigating to /w/mw-config (assuming your wiki is in a directory called w), and running the web installer without changing any settings on the way.