MediaWiki REL1_31
TestBagOStuff.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Session;
4
9
10 public function __construct() {
11 parent::__construct( new \HashBagOStuff );
12 }
13
18 public function setSessionData( $id, array $data ) {
19 $this->setSession( $id, [ 'data' => $data ] );
20 }
21
26 public function setSessionMeta( $id, array $metadata ) {
27 $this->setSession( $id, [ 'metadata' => $metadata ] );
28 }
29
34 public function setSession( $id, array $blob ) {
35 $blob += [
36 'data' => [],
37 'metadata' => [],
38 ];
39 $blob['metadata'] += [
40 'userId' => 0,
41 'userName' => null,
42 'userToken' => null,
43 'provider' => 'DummySessionProvider',
44 ];
45
46 $this->setRawSession( $id, $blob );
47 }
48
53 public function setRawSession( $id, $blob ) {
54 $expiry = \RequestContext::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' );
55 $this->set( $this->makeKey( 'MWSession', $id ), $blob, $expiry );
56 }
57
62 public function getSession( $id ) {
63 return $this->get( $this->makeKey( 'MWSession', $id ) );
64 }
65
70 public function getSessionFromBackend( $id ) {
71 return $this->backend->get( $this->makeKey( 'MWSession', $id ) );
72 }
73
77 public function deleteSession( $id ) {
78 $this->delete( $this->makeKey( 'MWSession', $id ) );
79 }
80
81}
Wrapper around a BagOStuff that caches data in memory.
makeKey( $class, $component=null)
Make a cache key, scoped to this instance's keyspace.
Simple store for keeping values in an associative array for the current process.
BagOStuff with utility functions for MediaWiki\\Session\\* testing.
setSessionData( $id, array $data)
setSessionMeta( $id, array $metadata)