18 TestingAccessWrapper::newFromObject( $backend )->requests = [ -1 =>
'dummy' ];
19 TestingAccessWrapper::newFromObject( $backend )->id =
new SessionId(
'abc' );
22 $priv = TestingAccessWrapper::newFromObject( $session );
27 $priv2 = TestingAccessWrapper::newFromObject( $session->sessionWithRequest(
$request ) );
28 $this->
assertSame( $backend, $priv2->backend );
42 ->setMethods( [ $m,
'deregisterSession' ] )
44 $mock->expects( $this->
once() )->method(
'deregisterSession' )
47 $tmp = $mock->expects( $this->
once() )->method( $m );
52 foreach (
$args as $arg ) {
74 [
'getId', [],
false,
true ],
75 [
'getSessionId', [],
false,
true ],
76 [
'resetId', [],
false,
true ],
77 [
'getProvider', [],
false,
true ],
78 [
'isPersistent', [],
false,
true ],
79 [
'persist', [],
false,
false ],
80 [
'unpersist', [],
false,
false ],
81 [
'shouldRememberUser', [],
false,
true ],
82 [
'setRememberUser', [
true ],
false,
false ],
83 [
'getRequest', [],
true,
true ],
84 [
'getUser', [],
false,
true ],
85 [
'getAllowedUserRights', [],
false,
true ],
86 [
'canSetUser', [],
false,
true ],
88 [
'suggestLoginUsername', [],
true,
true ],
89 [
'shouldForceHTTPS', [],
false,
true ],
90 [
'setForceHTTPS', [
true ],
false,
false ],
91 [
'getLoggedOutTimestamp', [],
false,
true ],
92 [
'setLoggedOutTimestamp', [ 123 ],
false,
false ],
93 [
'getProviderMetadata', [],
false,
true ],
94 [
'save', [],
false,
false ],
95 [
'delaySave', [],
false,
true ],
96 [
'renew', [],
false,
false ],
102 $backend = TestingAccessWrapper::newFromObject( $session )->backend;
109 $this->
assertEquals(
'default', $session->get(
'null',
'default' ) );
112 $session->set(
'foo', 55 );
115 $backend->dirty =
false;
117 $session->set( 1,
'one' );
120 $backend->dirty =
false;
122 $session->set( 1,
'one' );
125 $this->
assertTrue( $session->exists(
'foo' ) );
131 $session->remove(
'foo' );
134 $backend->dirty =
false;
135 $session->remove( 1 );
138 $backend->dirty =
false;
140 $session->remove( 101 );
143 $backend->data = [
'a',
'b',
'?' =>
'c' ];
149 foreach ( $session as $key =>
$value ) {
155 $this->
assertEquals( $backend->data, iterator_to_array( $session ) );
162 $backend = TestingAccessWrapper::newFromObject( $session )->backend;
168 $logger->setCollect(
true );
170 $logger->setCollect(
false );
173 [ LogLevel::DEBUG,
'Undefined index (auto-adds to session with a null value): null' ]
174 ], $logger->getBuffer() );
175 $logger->clearBuffer();
177 $session[
'foo'] = 55;
180 $backend->dirty =
false;
185 $backend->dirty =
false;
190 $session[
'bar'] = [
'baz' => [] ];
191 $session[
'bar'][
'baz'][
'quux'] = 2;
192 $this->
assertEquals( [
'baz' => [
'quux' => 2 ] ], $backend->data[
'bar'] );
194 $logger->setCollect(
true );
195 $session[
'bar2'][
'baz'][
'quux'] = 3;
196 $logger->setCollect(
false );
197 $this->
assertEquals( [
'baz' => [
'quux' => 3 ] ], $backend->data[
'bar2'] );
199 [ LogLevel::DEBUG,
'Undefined index (auto-adds to session with a null value): bar2' ]
200 ], $logger->getBuffer() );
201 $logger->clearBuffer();
203 $backend->dirty =
false;
211 unset( $session[
'foo'] );
214 $backend->dirty =
false;
215 unset( $session[1] );
218 $backend->dirty =
false;
220 unset( $session[101] );
226 $priv = TestingAccessWrapper::newFromObject( $session );
229 ->setMethods( [
'canSetUser',
'setUser',
'save' ] )
231 $backend->expects( $this->
once() )->method(
'canSetUser' )
233 $backend->expects( $this->
once() )->method(
'setUser' )
234 ->with( $this->callback(
function ( $user ) {
235 return $user instanceof
User && $user->
isAnon();
237 $backend->expects( $this->
once() )->method(
'save' );
238 $priv->backend = $backend;
244 ->setMethods( [
'canSetUser',
'setUser',
'save' ] )
247 $backend->expects( $this->
once() )->method(
'canSetUser' )
249 $backend->expects( $this->
once() )->method(
'setUser' )
250 ->with( $this->callback(
function ( $user ) {
251 return $user instanceof
User && $user->
isAnon();
253 $backend->expects( $this->
once() )->method(
'save' );
254 $priv->backend = $backend;
259 ->setMethods( [
'canSetUser',
'setUser',
'save' ] )
261 $backend->expects( $this->
once() )->method(
'canSetUser' )
263 $backend->expects( $this->never() )->method(
'setUser' );
264 $backend->expects( $this->
once() )->method(
'save' );
265 $priv->backend = $backend;
273 $priv = TestingAccessWrapper::newFromObject( $session );
274 $backend = $priv->backend;
276 $token = TestingAccessWrapper::newFromObject( $session->getToken() );
279 $secret = $backend->data[
'wsTokenSecrets'][
'default'];
284 $token = TestingAccessWrapper::newFromObject( $session->getToken(
'foo' ) );
289 $backend->data[
'wsTokenSecrets'][
'secret'] =
'sekret';
290 $token = TestingAccessWrapper::newFromObject(
291 $session->getToken( [
'bar',
'baz' ],
'secret' )
293 $this->
assertSame(
'sekret', $token->secret );
297 $session->resetToken(
'secret' );
302 $session->resetAllTokens();
314 $session->setSecret(
'secret',
$data );
323 [ [
'foo',
'bar' =>
'baz',
'subarray' => [ 1, 2, 3 ] ] ],
324 [ (
object)[
'foo',
'bar' =>
'baz',
'subarray' => [ 1, 2, 3 ] ] ],
336 $this->
assertEquals(
'defaulted', $session->getSecret(
'test',
'defaulted' ) );
339 $session->set(
'test',
'foobar' );
340 $logger->setCollect(
true );
341 $this->
assertEquals(
'defaulted', $session->getSecret(
'test',
'defaulted' ) );
342 $logger->setCollect(
false );
344 [ LogLevel::WARNING,
'Invalid sealed-secret format' ]
345 ], $logger->getBuffer() );
346 $logger->clearBuffer();
349 $session->setSecret(
'test',
'foobar' );
350 $encrypted = $session->get(
'test' );
351 $session->set(
'test', $encrypted .
'x' );
352 $logger->setCollect(
true );
353 $this->
assertEquals(
'defaulted', $session->getSecret(
'test',
'defaulted' ) );
354 $logger->setCollect(
false );
356 [ LogLevel::WARNING,
'Sealed secret has been tampered with, aborting.' ]
357 ], $logger->getBuffer() );
358 $logger->clearBuffer();
362 list( $encKey, $hmacKey ) = TestingAccessWrapper::newFromObject( $session )->getSecretKeys();
363 $ciphertext =
openssl_encrypt(
'foobar',
'aes-256-ctr', $encKey, OPENSSL_RAW_DATA, $iv );
365 $hmac =
hash_hmac(
'sha256', $sealed, $hmacKey,
true );
367 $session->set(
'test', $encrypted );
369 $this->
assertEquals(
'defaulted', $session->getSecret(
'test',
'defaulted' ) );
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
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,...
isAnon()
Get whether the user is anonymous.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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
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 & $ret
processing should stop and the error should be shown to the user * false
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object