18 $config->set(
'CookiePrefix',
'wgCookiePrefix' );
21 'sessionCookieName' =>
$name,
22 'sessionCookieOptions' => [],
24 if ( $prefix !==
null ) {
25 $params[
'sessionCookieOptions'][
'prefix'] = $prefix;
28 $provider = $this->
getMockBuilder( ImmutableSessionProviderWithCookie::class )
29 ->setConstructorArgs( [
$params ] )
30 ->getMockForAbstractClass();
32 $provider->setConfig( $config );
39 $provider = $this->
getMockBuilder( ImmutableSessionProviderWithCookie::class )
40 ->getMockForAbstractClass();
41 $priv = TestingAccessWrapper::newFromObject( $provider );
43 $this->
assertSame( [], $priv->sessionCookieOptions );
45 $provider = $this->
getMockBuilder( ImmutableSessionProviderWithCookie::class )
46 ->setConstructorArgs( [ [
47 'sessionCookieName' =>
'Foo',
48 'sessionCookieOptions' => [
'Bar' ],
50 ->getMockForAbstractClass();
51 $priv = TestingAccessWrapper::newFromObject( $provider );
52 $this->
assertSame(
'Foo', $priv->sessionCookieName );
53 $this->
assertSame( [
'Bar' ], $priv->sessionCookieOptions );
56 $provider = $this->
getMockBuilder( ImmutableSessionProviderWithCookie::class )
57 ->setConstructorArgs( [ [
58 'sessionCookieName' =>
false,
60 ->getMockForAbstractClass();
61 $this->fail(
'Expected exception not thrown' );
62 }
catch ( \InvalidArgumentException $ex ) {
64 'sessionCookieName must be a string',
70 $provider = $this->
getMockBuilder( ImmutableSessionProviderWithCookie::class )
71 ->setConstructorArgs( [ [
72 'sessionCookieOptions' =>
'x',
74 ->getMockForAbstractClass();
75 $this->fail(
'Expected exception not thrown' );
76 }
catch ( \InvalidArgumentException $ex ) {
78 'sessionCookieOptions must be an array',
86 $this->
assertFalse( $provider->persistsSessionID() );
90 $this->
assertTrue( $provider->persistsSessionID() );
93 $msg = $provider->whyNoSession();
95 $this->
assertSame(
'sessionprovider-nocookies', $msg->getKey() );
100 $this->
assertSame( [], $provider->getVaryCookies() );
103 $this->
assertSame( [
'wgCookiePrefixFoo' ], $provider->getVaryCookies() );
106 $this->
assertSame( [
'BarFoo' ], $provider->getVaryCookies() );
109 $this->
assertSame( [
'Foo' ], $provider->getVaryCookies() );
113 $this->
setMwGlobals(
'wgCookiePrefix',
'wgCookiePrefix' );
116 '' =>
'empty---------------------------',
117 'Foo' =>
'foo-----------------------------',
118 'wgCookiePrefixFoo' =>
'wgfoo---------------------------',
119 'BarFoo' =>
'foobar--------------------------',
123 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
null ) );
125 $provider->getSessionIdFromCookie(
$request );
126 $this->fail(
'Expected exception not thrown' );
127 }
catch ( \BadMethodCallException $ex ) {
129 'MediaWiki\\Session\\ImmutableSessionProviderWithCookie::getSessionIdFromCookie ' .
130 'may not be called when $this->sessionCookieName === null',
135 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
'Foo' ) );
137 'wgfoo---------------------------',
138 $provider->getSessionIdFromCookie(
$request )
141 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
'Foo',
'Bar' ) );
143 'foobar--------------------------',
144 $provider->getSessionIdFromCookie(
$request )
147 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
'Foo',
'' ) );
149 'foo-----------------------------',
150 $provider->getSessionIdFromCookie(
$request )
153 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
'bad',
'' ) );
156 $provider = TestingAccessWrapper::newFromObject( $this->
getProvider(
'none',
'' ) );
162 ->setMethods( [
'headersSent',
'setCookie',
'header' ] )
164 $sentResponse->expects( $this->
any() )->method(
'headersSent' )
166 $sentResponse->expects( $this->never() )->method(
'setCookie' );
167 $sentResponse->expects( $this->never() )->method(
'header' );
170 ->setMethods( [
'response' ] )->getMock();
171 $sentRequest->expects( $this->
any() )->method(
'response' )
183 'wgCookieExpiration' => 100,
184 'wgSecureLogin' =>
false,
188 $provider->setLogger(
new \Psr\Log\NullLogger() );
189 $priv = TestingAccessWrapper::newFromObject( $provider );
190 $priv->sessionCookieOptions = [
192 'path' =>
'CookiePath',
193 'domain' =>
'CookieDomain',
198 $sessionId =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
200 $this->
assertFalse( $user->requiresHTTPS(),
'sanity check' );
205 'provider' => $provider,
212 new \Psr\Log\NullLogger(),
215 TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling =
false;
216 $backend->setRememberUser( $remember );
217 $backend->setForceHTTPS( $secure );
220 $priv->sessionCookieName =
null;
222 $provider->persistSession( $backend,
$request );
226 $priv->sessionCookieName =
'session';
229 $provider->persistSession( $backend,
$request );
231 $cookie =
$request->response()->getCookieData(
'xsession' );
233 if (
isset( $cookie[
'expire'] ) && $cookie[
'expire'] > 0 ) {
235 $cookie[
'expire'] =
round( $cookie[
'expire'] -
$time, -2 );
238 'value' => $sessionId,
240 'path' =>
'CookiePath',
241 'domain' =>
'CookieDomain',
247 $cookie =
$request->response()->getCookieData(
'forceHTTPS' );
250 if (
isset( $cookie[
'expire'] ) && $cookie[
'expire'] > 0 ) {
252 $cookie[
'expire'] =
round( $cookie[
'expire'] -
$time, -2 );
257 'path' =>
'CookiePath',
258 'domain' =>
'CookieDomain',
269 $provider->persistSession( $backend,
$request );
284 $provider->setLogger(
new \Psr\Log\NullLogger() );
285 $priv = TestingAccessWrapper::newFromObject( $provider );
288 $priv->sessionCookieName =
null;
290 $provider->unpersistSession(
$request );
294 $priv->sessionCookieName =
'session';
296 $provider->unpersistSession(
$request );
301 $provider->unpersistSession(
$request );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
A logger that may be configured to either buffer logs or to print them to the output where PHPUnit wi...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
see documentation in includes Linker php for Linker::makeImageLink & $time
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false