55 parent::__construct();
58 'cookieOptions' => [],
63 if ( !isset(
$params[
'priority'] ) ) {
64 throw new \InvalidArgumentException( __METHOD__ .
': priority must be specified' );
69 throw new \InvalidArgumentException( __METHOD__ .
': Invalid priority' );
72 if ( !is_array(
$params[
'cookieOptions'] ) ) {
73 throw new \InvalidArgumentException( __METHOD__ .
': cookieOptions must be an array' );
76 $this->priority =
$params[
'priority'];
77 $this->cookieOptions =
$params[
'cookieOptions'];
79 unset( $this->params[
'priority'] );
80 unset( $this->params[
'cookieOptions'] );
89 'callUserSetCookiesHook' =>
false,
95 $this->cookieOptions += [
101 'httpOnly' =>
$config->
get(
'CookieHttpOnly' ),
106 $sessionId = $this->
getCookie( $request, $this->params[
'sessionName'],
'' );
109 'forceHTTPS' => $this->
getCookie( $request,
'forceHTTPS',
'',
false )
112 $info[
'id'] = $sessionId;
113 $info[
'persisted'] =
true;
117 if ( $userId !==
null ) {
120 }
catch ( \InvalidArgumentException $ex ) {
125 if ( $userName !==
null && $userInfo->getName() !== $userName ) {
126 $this->logger->warning(
127 'Session "{session}" requested with mismatched UserID and UserName cookies.',
129 'session' => $sessionId,
132 'cookie_username' => $userName,
133 'username' => $userInfo->getName(),
139 if ( $token !==
null ) {
140 if ( !hash_equals( $userInfo->getToken(), $token ) ) {
141 $this->logger->warning(
142 'Session "{session}" requested with invalid Token cookie.',
144 'session' => $sessionId,
146 'username' => $userInfo->getName(),
150 $info[
'userInfo'] = $userInfo->verified();
151 $info[
'persisted'] =
true;
152 } elseif ( isset( $info[
'id'] ) ) {
153 $info[
'userInfo'] = $userInfo;
159 } elseif ( isset( $info[
'id'] ) ) {
165 $this->logger->debug(
166 'Session "{session}" requested without UserID cookie',
168 'session' => $info[
'id'],
192 $this->logger->debug( __METHOD__ .
': Headers already sent' );
202 if ( $this->params[
'callUserSetCookiesHook'] && !
$user->isAnon() ) {
203 \Hooks::run(
'UserSetCookies', [
$user, &$sessionData, &$cookies ] );
213 $options[
'secure'] = $this->config->get(
'CookieSecure' );
216 $response->setCookie( $this->params[
'sessionName'], $session->
getId(),
null,
220 foreach ( $cookies
as $key =>
$value ) {
225 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
233 if ( $sessionData ) {
234 $session->
addData( $sessionData );
242 $this->logger->debug( __METHOD__ .
': Headers already sent' );
252 $this->params[
'sessionName'], [
'prefix' =>
'' ] + $this->cookieOptions
255 foreach ( $cookies
as $key =>
$value ) {
256 $response->clearCookie( $key, $this->cookieOptions );
273 if ( $backend->shouldRememberUser() ) {
278 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
282 $response->setCookie(
'forceHTTPS',
'true', $expiration,
283 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
286 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
296 if ( $loggedOut + 86400 > time() &&
297 $loggedOut !== (
int)$this->
getCookie( $request,
'LoggedOut', $this->cookieOptions[
'prefix'] )
299 $request->response()->setCookie(
'LoggedOut', $loggedOut, $loggedOut + 86400,
300 $this->cookieOptions );
308 $this->cookieOptions[
'prefix'] .
'Token',
309 $this->cookieOptions[
'prefix'] .
'LoggedOut',
310 $this->params[
'sessionName'],
316 $name = $this->
getCookie( $request,
'UserName', $this->cookieOptions[
'prefix'] );
317 if (
$name !==
null ) {
318 $name = User::getCanonicalName(
$name,
'usable' );
329 $prefix = $this->cookieOptions[
'prefix'];
347 if (
$value ===
'deleted' ) {
365 if (
$user->isAnon() ) {
372 'UserID' =>
$user->getId(),
373 'UserName' =>
$user->getName(),
374 'Token' => $remember ? (
string)
$user->getToken() :
false,
387 if ( !
$user->isAnon() && $this->params[
'callUserSetCookiesHook'] ) {
389 'wsUserID' =>
$user->getId(),
390 'wsToken' =>
$user->getToken(),
391 'wsUserName' =>
$user->getName(),
399 return wfMessage(
'sessionprovider-nocookies' );
414 return [
'UserID',
'UserName',
'Token' ];
429 $normalExpiration = $this->config->get(
'CookieExpiration' );
431 if ( $shouldRememberUser && in_array( $cookieName, $extendedCookies,
true ) ) {
432 $extendedExpiration = $this->config->get(
'ExtendedLoginCookieExpiration' );
434 return ( $extendedExpiration !==
null ) ? (int)$extendedExpiration : (int)$normalExpiration;
436 return (
int)$normalExpiration;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
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 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
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
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 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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
error also a ContextSource you ll probably need to make sure the header is varied on $request
this hook is for auditing only $response
Allows to change the fields on the form that will be generated $name
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.".