83 self::$executeContext &&
84 self::$executeContext[
'stage'] >= $stage &&
90 self::$executeContext[
'subqueue'][] = $update;
95 if ( $stage === self::PRESEND ) {
96 self::push( self::$preSendUpdates, $update );
98 self::push( self::$postSendUpdates, $update );
104 self::tryOpportunisticExecute(
'run' );
119 $callable, $stage = self::POSTSEND, $dbw =
null
130 public static function doUpdates( $mode =
'run', $stage = self::ALL ) {
131 $stageEffective = ( $stage === self::ALL ) ? self::POSTSEND : $stage;
135 if ( $stage === self::ALL || $stage === self::PRESEND ) {
136 self::execute( self::$preSendUpdates, $mode, $stageEffective );
139 if ( $stage === self::ALL || $stage == self::POSTSEND ) {
140 self::execute( self::$postSendUpdates, $mode, $stageEffective );
142 }
while ( $stage === self::ALL && self::$preSendUpdates );
151 $class = get_class( $update );
152 if ( isset(
$queue[$class] ) ) {
154 $existingUpdate =
$queue[$class];
155 $existingUpdate->merge( $update );
159 $queue[$class] = $existingUpdate;
178 $services = MediaWikiServices::getInstance();
179 $stats =
$services->getStatsdDataFactory();
180 $lbFactory =
$services->getDBLoadBalancerFactory();
181 $method = RequestContext::getMain()->getRequest()->getMethod();
183 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
186 $reportableError =
null;
195 $updatesByType = [
'data' => [],
'generic' => [] ];
196 foreach ( $updates
as $du ) {
198 $du->setTransactionTicket( $ticket );
199 $updatesByType[
'data'][] = $du;
201 $updatesByType[
'generic'][] = $du;
205 ? get_class( $du ) .
'-' . $du->getOrigin()
207 $stats->increment(
'deferred_updates.' . $method .
'.' .
$name );
211 foreach ( $updatesByType
as $updatesForType ) {
212 foreach ( $updatesForType
as $update ) {
213 self::$executeContext = [
'stage' => $stage,
'subqueue' => [] ];
216 $guiError = self::runUpdate( $update, $lbFactory, $mode, $stage );
217 $reportableError = $reportableError ?: $guiError;
219 while ( self::$executeContext[
'subqueue'] ) {
220 $subUpdate = reset( self::$executeContext[
'subqueue'] );
221 $firstKey =
key( self::$executeContext[
'subqueue'] );
222 unset( self::$executeContext[
'subqueue'][$firstKey] );
225 $subUpdate->setTransactionTicket( $ticket );
228 $guiError = self::runUpdate( $subUpdate, $lbFactory, $mode, $stage );
229 $reportableError = $reportableError ?: $guiError;
235 self::$executeContext =
null;
243 if ( $reportableError ) {
244 throw $reportableError;
262 $spec = $update->getAsJobSpecification();
263 JobQueueGroup::singleton( $spec[
'wiki'] )->push( $spec[
'job'] );
268 $fnameTrxOwner = get_class( $update ) .
'::doUpdate';
273 }
catch ( Exception
$e ) {
278 MWExceptionHandler::rollbackMasterChangesAndLog(
$e );
282 if ( defined(
'MW_PHPUNIT_TEST' ) ) {
303 if ( self::$executeContext ) {
308 if ( !self::areDatabaseTransactionsActive() ) {
309 self::doUpdates( $mode );
313 if ( self::pendingUpdatesCount() >= self::BIG_QUEUE_SIZE ) {
316 self::$preSendUpdates = self::enqueueUpdates( self::$preSendUpdates );
317 self::$postSendUpdates = self::enqueueUpdates( self::$postSendUpdates );
320 return !self::pendingUpdatesCount();
332 foreach ( $updates
as $update ) {
334 $spec = $update->getAsJobSpecification();
335 JobQueueGroup::singleton( $spec[
'wiki'] )->push( $spec[
'job'] );
337 $remaining[] = $update;
349 return count( self::$preSendUpdates ) + count( self::$postSendUpdates );
359 if ( $stage === self::ALL || $stage === self::PRESEND ) {
360 $updates = array_merge( $updates, self::$preSendUpdates );
362 if ( $stage === self::ALL || $stage === self::POSTSEND ) {
363 $updates = array_merge( $updates, self::$postSendUpdates );
373 self::$preSendUpdates = [];
374 self::$postSendUpdates = [];
381 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
382 if ( $lbFactory->hasTransactionRound() || !$lbFactory->isReadyForRoundOperations() ) {
387 $lbFactory->forEachLB(
function (
LoadBalancer $lb )
use ( &$connsBusy ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
global $wgCommandLineMode
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Abstract base class for update jobs that do something with some secondary data extracted from article...
Class for managing the deferred updates.
static enqueueUpdates(array $updates)
Enqueue a job for each EnqueueableDataUpdate item and return the other items.
static runUpdate(DeferrableUpdate $update, LBFactory $lbFactory, $mode, $stage)
static doUpdates( $mode='run', $stage=self::ALL)
Do any deferred updates and clear the list.
static areDatabaseTransactionsActive()
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
static pendingUpdatesCount()
static tryOpportunisticExecute( $mode='run')
Run all deferred updates immediately if there are no DB writes active.
static push(array &$queue, DeferrableUpdate $update)
static clearPendingUpdates()
Clear all pending updates without performing them.
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
static array null $executeContext
Information about the current execute() call or null if not running.
static DeferrableUpdate[] $preSendUpdates
Updates to be deferred until before request end.
static execute(array &$queue, $mode, $stage)
Immediately run/queue a list of updates.
static DeferrableUpdate[] $postSendUpdates
Updates to be deferred until after request end.
static getPendingUpdates( $stage=self::ALL)
An error page which can definitely be safely rendered using the OutputPage.
Deferrable Update for closure/callback.
Deferrable update that must run outside of any explicit LBFactory transaction round.
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 key
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Allows to change the fields on the form that will be generated $name
returning false will NOT prevent logging $e
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
Callback wrapper that has an originating method.
Interface that deferrable updates should implement.
doUpdate()
Perform the actual work.
Interface that marks a DataUpdate as enqueuable via the JobQueue.
Interface that deferrable updates can implement.
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))