59 parent::__construct();
62 'cookieOptions' => [],
67 if ( !isset(
$params[
'priority'] ) ) {
68 throw new \InvalidArgumentException( __METHOD__ .
': priority must be specified' );
73 throw new \InvalidArgumentException( __METHOD__ .
': Invalid priority' );
76 if ( !is_array(
$params[
'cookieOptions'] ) ) {
77 throw new \InvalidArgumentException( __METHOD__ .
': cookieOptions must be an array' );
80 $this->priority =
$params[
'priority'];
81 $this->cookieOptions =
$params[
'cookieOptions'];
83 unset( $this->params[
'priority'] );
84 unset( $this->params[
'cookieOptions'] );
93 'callUserSetCookiesHook' =>
false,
98 $this->useCrossSiteCookies = strcasecmp(
$config->
get(
'CookieSameSite' ),
'none' ) === 0;
101 $this->cookieOptions += [
106 'secure' =>
$config->
get(
'CookieSecure' ) || $this->config->get(
'ForceHTTPS' ),
107 'httpOnly' =>
$config->
get(
'CookieHttpOnly' ),
108 'sameSite' =>
$config->
get(
'CookieSameSite' ),
113 $sessionId = $this->
getCookie( $request, $this->params[
'sessionName'],
'' );
116 'forceHTTPS' => $this->
getCookie( $request,
'forceHTTPS',
'',
false )
119 $info[
'id'] = $sessionId;
120 $info[
'persisted'] =
true;
124 if ( $userId !==
null ) {
127 }
catch ( \InvalidArgumentException $ex ) {
132 if ( $userName !==
null && $userInfo->getName() !== $userName ) {
133 $this->logger->warning(
134 'Session "{session}" requested with mismatched UserID and UserName cookies.',
136 'session' => $sessionId,
139 'cookie_username' => $userName,
140 'username' => $userInfo->getName(),
146 if ( $token !==
null ) {
147 if ( !hash_equals( $userInfo->getToken(), $token ) ) {
148 $this->logger->warning(
149 'Session "{session}" requested with invalid Token cookie.',
151 'session' => $sessionId,
153 'username' => $userInfo->getName(),
157 $info[
'userInfo'] = $userInfo->verified();
158 $info[
'persisted'] =
true;
159 } elseif ( isset( $info[
'id'] ) ) {
160 $info[
'userInfo'] = $userInfo;
166 } elseif ( isset( $info[
'id'] ) ) {
172 $this->logger->debug(
173 'Session "{session}" requested without UserID cookie',
175 'session' => $info[
'id'],
199 $this->logger->debug( __METHOD__ .
': Headers already sent' );
209 if ( $this->params[
'callUserSetCookiesHook'] && !$user->isAnon() ) {
210 \Hooks::run(
'UserSetCookies', [ $user, &$sessionData, &$cookies ] );
217 $options[
'secure'] = $this->config->get(
'CookieSecure' )
218 || $this->config->get(
'ForceHTTPS' );
221 $response->setCookie( $this->params[
'sessionName'], $session->
getId(),
null,
225 foreach ( $cookies as $key =>
$value ) {
230 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
238 if ( $sessionData ) {
239 $session->
addData( $sessionData );
247 $this->logger->debug( __METHOD__ .
': Headers already sent' );
257 $this->params[
'sessionName'], [
'prefix' =>
'' ] + $this->cookieOptions
260 foreach ( $cookies as $key =>
$value ) {
261 $response->clearCookie( $key, $this->cookieOptions );
277 if ( $this->config->get(
'ForceHTTPS' ) ) {
283 if ( $backend->shouldRememberUser() ) {
288 $expiration = $expirationDuration ? $expirationDuration + time() :
null;
292 $response->setCookie(
'forceHTTPS',
'true', $expiration,
293 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
296 [
'prefix' =>
'',
'secure' =>
false ] + $this->cookieOptions );
306 if ( $loggedOut + 86400 > time() &&
307 $loggedOut !== (
int)$this->
getCookie( $request,
'LoggedOut', $this->cookieOptions[
'prefix'] )
309 $request->response()->setCookie(
'LoggedOut', $loggedOut, $loggedOut + 86400,
310 $this->cookieOptions );
318 $this->cookieOptions[
'prefix'] .
'Token',
319 $this->cookieOptions[
'prefix'] .
'LoggedOut',
320 $this->params[
'sessionName'],
326 $name = $this->
getCookie( $request,
'UserName', $this->cookieOptions[
'prefix'] );
327 if ( $name !==
null ) {
330 return $name ===
false ? null :
$name;
339 $prefix = $this->cookieOptions[
'prefix'];
356 if ( $this->useCrossSiteCookies ) {
361 if (
$value ===
'deleted' ) {
379 if ( $user->isAnon() ) {
386 'UserID' => $user->getId(),
387 'UserName' => $user->getName(),
388 'Token' => $remember ? (
string)$user->getToken() :
false,
401 if ( !$user->isAnon() && $this->params[
'callUserSetCookiesHook'] ) {
403 'wsUserID' => $user->getId(),
404 'wsToken' => $user->getToken(),
405 'wsUserName' => $user->getName(),
413 return wfMessage(
'sessionprovider-nocookies' );
428 return [
'UserID',
'UserName',
'Token' ];
443 $normalExpiration = $this->config->get(
'CookieExpiration' );
445 if ( $shouldRememberUser && in_array( $cookieName, $extendedCookies,
true ) ) {
446 $extendedExpiration = $this->config->get(
'ExtendedLoginCookieExpiration' );
448 return ( $extendedExpiration !==
null ) ? (int)$extendedExpiration : (int)$normalExpiration;
450 return (
int)$normalExpiration;
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
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
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
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
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
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
Allows to change the fields on the form that will be generated $name
this hook is for auditing only $response
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".