27use Psr\Log\LoggerInterface;
128 $phpSessionHandling = \RequestContext::getMain()->getConfig()->get(
'PHPSessionHandling' );
129 $this->usePhpSessionHandling = $phpSessionHandling !==
'disable';
132 throw new \InvalidArgumentException(
133 "Refusing to create session for unverified user {$info->getUserInfo()}"
137 throw new \InvalidArgumentException(
'Cannot create session without a provider' );
140 throw new \InvalidArgumentException(
'SessionId and SessionInfo don\'t match' );
155 if ( !is_array(
$blob ) ||
156 !isset(
$blob[
'metadata'] ) || !is_array(
$blob[
'metadata'] ) ||
157 !isset(
$blob[
'data'] ) || !is_array(
$blob[
'data'] )
160 $this->dataDirty =
true;
161 $this->metaDirty =
true;
162 $this->logger->debug(
163 'SessionBackend "{session}" is unsaved, marking dirty in constructor',
165 'session' => $this->
id,
169 if ( isset(
$blob[
'metadata'][
'loggedOut'] ) ) {
170 $this->loggedOut = (int)
$blob[
'metadata'][
'loggedOut'];
172 if ( isset(
$blob[
'metadata'][
'expires'] ) ) {
173 $this->expires = (int)
$blob[
'metadata'][
'expires'];
175 $this->metaDirty =
true;
176 $this->logger->debug(
177 'SessionBackend "{session}" metadata dirty due to missing expiration timestamp',
179 'session' => $this->
id,
194 $session =
new Session( $this, $index, $this->logger );
204 unset( $this->requests[$index] );
205 if ( !$this->
shutdown && !count( $this->requests ) ) {
207 $this->provider->getManager()->deregisterSessionBackend( $this );
242 if ( $this->provider->persistsSessionId() ) {
243 $oldId = (
string)$this->
id;
244 $restart = $this->usePhpSessionHandling && $oldId === session_id() &&
250 session_write_close();
253 $this->provider->getManager()->changeBackendId( $this );
254 $this->provider->sessionIdWasReset( $this, $oldId );
255 $this->metaDirty =
true;
256 $this->logger->debug(
257 'SessionBackend "{session}" metadata dirty due to ID reset (formerly "{oldId}")',
259 'session' => $this->
id,
264 session_id( (
string)$this->
id );
265 \Wikimedia\quietCall(
'session_start' );
271 $this->store->delete( $this->store->makeKey(
'MWSession', $oldId ) );
305 $this->forcePersist =
true;
306 $this->metaDirty =
true;
307 $this->logger->debug(
308 'SessionBackend "{session}" force-persist due to persist()',
310 'session' => $this->
id,
325 session_id() === (
string)$this->
id
327 $this->logger->debug(
328 'SessionBackend "{session}" Closing PHP session for unpersist',
329 [
'session' => $this->
id ]
331 session_write_close();
336 $this->forcePersist =
true;
337 $this->metaDirty =
true;
341 $this->store->delete( $this->store->makeKey(
'MWSession', (
string)$this->id ) );
362 if ( $this->remember !== (
bool)
$remember ) {
364 $this->metaDirty =
true;
365 $this->logger->debug(
366 'SessionBackend "{session}" metadata dirty due to remember-user change',
368 'session' => $this->
id,
380 if ( !isset( $this->requests[$index] ) ) {
381 throw new \InvalidArgumentException(
'Invalid session index' );
383 return $this->requests[$index];
399 return $this->provider->getAllowedUserRights( $this );
407 return $this->provider->canChangeUser();
419 throw new \BadMethodCallException(
420 'Cannot set user on this session; check $session->canSetUser() first'
425 $this->metaDirty =
true;
426 $this->logger->debug(
427 'SessionBackend "{session}" metadata dirty due to user change',
429 'session' => $this->
id,
440 if ( !isset( $this->requests[$index] ) ) {
441 throw new \InvalidArgumentException(
'Invalid session index' );
443 return $this->provider->suggestLoginUsername( $this->requests[$index] );
459 if ( $this->forceHTTPS !== (
bool)$force ) {
460 $this->forceHTTPS = (bool)$force;
461 $this->metaDirty =
true;
462 $this->logger->debug(
463 'SessionBackend "{session}" metadata dirty due to force-HTTPS change',
465 'session' => $this->
id,
485 if ( $this->loggedOut !== $ts ) {
486 $this->loggedOut = $ts;
487 $this->metaDirty =
true;
488 $this->logger->debug(
489 'SessionBackend "{session}" metadata dirty due to logged-out-timestamp change',
491 'session' => $this->
id,
512 if ( $metadata !==
null && !is_array( $metadata ) ) {
513 throw new \InvalidArgumentException(
'$metadata must be an array or null' );
515 if ( $this->providerMetadata !== $metadata ) {
516 $this->providerMetadata = $metadata;
517 $this->metaDirty =
true;
518 $this->logger->debug(
519 'SessionBackend "{session}" metadata dirty due to provider metadata change',
521 'session' => $this->
id,
549 foreach ( $newData
as $key =>
$value ) {
552 $this->dataDirty =
true;
553 $this->logger->debug(
554 'SessionBackend "{session}" data dirty due to addData(): {callers}',
556 'session' => $this->
id,
568 $this->dataDirty =
true;
569 $this->logger->debug(
570 'SessionBackend "{session}" data dirty due to dirty(): {callers}',
572 'session' => $this->
id,
584 if ( time() + $this->lifetime / 2 > $this->expires ) {
585 $this->metaDirty =
true;
586 $this->logger->debug(
587 'SessionBackend "{callers}" metadata dirty for renew(): {callers}',
589 'session' => $this->
id,
593 $this->forcePersist =
true;
594 $this->logger->debug(
595 'SessionBackend "{session}" force-persist for renew(): {callers}',
597 'session' => $this->
id,
614 return new \Wikimedia\ScopedCallback(
function () {
641 public function save( $closing =
false ) {
642 $anon = $this->
user->isAnon();
644 if ( !$anon && $this->provider->getManager()->isUserSessionPrevented( $this->user->getName() ) ) {
645 $this->logger->debug(
646 'SessionBackend "{session}" not saving, user {user} was ' .
647 'passed to SessionManager::preventSessionsForUser',
649 'session' => $this->
id,
650 'user' => $this->
user,
657 if ( !$anon && !$this->
user->getToken(
false ) ) {
658 $this->logger->debug(
659 'SessionBackend "{session}" creating token for user {user} on save',
661 'session' => $this->
id,
662 'user' => $this->
user,
664 $this->
user->setToken();
668 \DeferredUpdates::addCallableUpdate(
function ()
use (
$user ) {
672 $this->metaDirty =
true;
676 if ( !$this->metaDirty && !$this->dataDirty &&
679 $this->logger->debug(
680 'SessionBackend "{session}" data dirty due to hash mismatch, {expected} !== {got}',
682 'session' => $this->
id,
683 'expected' => $this->dataHash,
686 $this->dataDirty =
true;
689 if ( !$this->metaDirty && !$this->dataDirty && !$this->forcePersist ) {
693 $this->logger->debug(
694 'SessionBackend "{session}" save: dataDirty={dataDirty} ' .
695 'metaDirty={metaDirty} forcePersist={forcePersist}',
697 'session' => $this->
id,
698 'dataDirty' => (
int)$this->dataDirty,
699 'metaDirty' => (
int)$this->metaDirty,
700 'forcePersist' => (
int)$this->forcePersist,
704 if ( $this->metaDirty || $this->forcePersist ) {
708 $this->provider->persistSession( $this,
$request );
715 if (
$request->getSessionId() === $this->id ) {
716 $this->provider->unpersistSession(
$request );
722 $this->forcePersist =
false;
724 if ( !$this->metaDirty && !$this->dataDirty ) {
729 $metadata = $origMetadata = [
730 'provider' => (
string)$this->provider,
731 'providerMetadata' => $this->providerMetadata,
732 'userId' => $anon ? 0 : $this->
user->getId(),
734 'userToken' => $anon ?
null : $this->
user->getToken(),
742 \Hooks::run(
'SessionMetadata', [ $this, &$metadata, $this->requests ] );
744 foreach ( $origMetadata
as $k => $v ) {
745 if ( $metadata[$k] !== $v ) {
746 throw new \UnexpectedValueException(
"SessionMetadata hook changed metadata key \"$k\"" );
750 $flags = $this->
persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY;
751 $flags |= CachedBagOStuff::WRITE_SYNC;
753 $this->store->makeKey(
'MWSession', (
string)$this->id ),
755 'data' => $this->data,
756 'metadata' => $metadata,
758 $metadata[
'expires'],
762 $this->metaDirty =
false;
763 $this->dataDirty =
false;
765 $this->expires = $metadata[
'expires'];
773 if ( !$this->checkPHPSessionRecursionGuard ) {
774 $this->checkPHPSessionRecursionGuard =
true;
775 $reset = new \Wikimedia\ScopedCallback(
function () {
776 $this->checkPHPSessionRecursionGuard =
false;
782 $this->logger->debug(
783 'SessionBackend "{session}" Taking over PHP session',
785 'session' => $this->
id,
787 session_id( (
string)$this->
id );
788 \Wikimedia\quietCall(
'session_start' );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetAllCallers( $limit=3)
Return a string consisting of callers in the stack.
Wrapper around a BagOStuff that caches data in memory.
makeKey( $class, $component=null)
Make a cache key, scoped to this instance's keyspace.
get( $key, $flags=0)
Get an item with the given key.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static isValidUserName( $name)
Is the input a valid username?
saveSettings()
Save this user's settings into the database.
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 save
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
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
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
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
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data