Go to the documentation of this file.
58 parent::__construct();
61 'cookieOptions' => [],
66 if ( !isset(
$params[
'priority'] ) ) {
67 throw new \InvalidArgumentException( __METHOD__ .
': priority must be specified' );
72 throw new \InvalidArgumentException( __METHOD__ .
': Invalid priority' );
75 if ( !is_array(
$params[
'cookieOptions'] ) ) {
76 throw new \InvalidArgumentException( __METHOD__ .
': cookieOptions must be an array' );
79 $this->priority =
$params[
'priority'];
80 $this->cookieOptions =
$params[
'cookieOptions'];
82 unset( $this->params[
'priority'] );
83 unset( $this->params[
'cookieOptions'] );
92 'callUserSetCookiesHook' =>
false,
98 $this->cookieOptions += [
104 'httpOnly' =>
$config->
get(
'CookieHttpOnly' ),
109 $sessionId = $this->
getCookie( $request, $this->params[
'sessionName'],
'' );
112 'forceHTTPS' => $this->
getCookie( $request,
'forceHTTPS',
'',
false )
115 $info[
'id'] = $sessionId;
116 $info[
'persisted'] =
true;
120 if ( $userId !==
null ) {
123 }
catch ( \InvalidArgumentException $ex ) {
128 if ( $userName !==
null && $userInfo->getName() !== $userName ) {
129 $this->logger->warning(
130 'Session "{session}" requested with mismatched UserID and UserName cookies.',
132 'session' => $sessionId,
135 'cookie_username' => $userName,
136 'username' => $userInfo->getName(),
142 if ( $token !==
null ) {
143 if ( !hash_equals( $userInfo->getToken(), $token ) ) {
144 $this->logger->warning(
145 'Session "{session}" requested with invalid Token cookie.',
147 'session' => $sessionId,
149 'username' => $userInfo->getName(),
153 $info[
'userInfo'] = $userInfo->verified();
154 $info[
'persisted'] =
true;
155 } elseif ( isset( $info[
'id'] ) ) {
156 $info[
'userInfo'] = $userInfo;
162 } elseif ( isset( $info[
'id'] ) ) {
168 $this->logger->debug(
169 'Session "{session}" requested without UserID cookie',
171 'session' => $info[
'id'],
195 $this->logger->debug( __METHOD__ .
': Headers already sent' );
205 if ( $this->params[
'callUserSetCookiesHook'] && !
$user->isAnon() ) {
216 $options[
'secure'] = $this->config->get(
'CookieSecure' );
219 $response->setCookie( $this->params[
'sessionName'], $session->
getId(),
null,
223 foreach ( $cookies
as $key =>
$value ) {
228 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
236 if ( $sessionData ) {
237 $session->
addData( $sessionData );
245 $this->logger->debug( __METHOD__ .
': Headers already sent' );
255 $this->params[
'sessionName'], [
'prefix' =>
'' ] + $this->cookieOptions
258 foreach ( $cookies
as $key =>
$value ) {
259 $response->clearCookie( $key, $this->cookieOptions );
276 if ( $backend->shouldRememberUser() ) {
281 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
285 $response->setCookie(
'forceHTTPS',
'true', $expiration,
286 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
289 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
299 if ( $loggedOut + 86400 > time() &&
300 $loggedOut !== (
int)$this->
getCookie( $request,
'LoggedOut', $this->cookieOptions[
'prefix'] )
302 $request->response()->setCookie(
'LoggedOut', $loggedOut, $loggedOut + 86400,
303 $this->cookieOptions );
311 $this->cookieOptions[
'prefix'] .
'Token',
312 $this->cookieOptions[
'prefix'] .
'LoggedOut',
313 $this->params[
'sessionName'],
319 $name = $this->
getCookie( $request,
'UserName', $this->cookieOptions[
'prefix'] );
320 if (
$name !==
null ) {
332 $prefix = $this->cookieOptions[
'prefix'];
350 if (
$value ===
'deleted' ) {
368 if (
$user->isAnon() ) {
375 'UserID' =>
$user->getId(),
376 'UserName' =>
$user->getName(),
377 'Token' => $remember ? (
string)
$user->getToken() :
false,
390 if ( !
$user->isAnon() && $this->params[
'callUserSetCookiesHook'] ) {
392 'wsUserID' =>
$user->getId(),
393 'wsToken' =>
$user->getToken(),
394 'wsUserName' =>
$user->getName(),
402 return wfMessage(
'sessionprovider-nocookies' );
417 return [
'UserID',
'UserName',
'Token' ];
432 $normalExpiration = $this->config->get(
'CookieExpiration' );
434 if ( $shouldRememberUser && in_array( $cookieName, $extendedCookies,
true ) ) {
435 $extendedExpiration = $this->config->get(
'ExtendedLoginCookieExpiration' );
437 return ( $extendedExpiration !==
null ) ? (int)$extendedExpiration : (
int)$normalExpiration;
439 return (
int)$normalExpiration;
return true to allow those checks to and false if checking is done & $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
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
Allows to change the fields on the form that will be generated $name
this hook is for auditing only $response
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
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 & $options
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.