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
133 public static function doUpdates( $mode =
'run', $stage = self::ALL ) {
134 $stageEffective = ( $stage === self::ALL ) ? self::POSTSEND : $stage;
138 if ( $stage === self::ALL || $stage === self::PRESEND ) {
139 self::execute( self::$preSendUpdates, $mode, $stageEffective );
142 if ( $stage === self::ALL || $stage == self::POSTSEND ) {
143 self::execute( self::$postSendUpdates, $mode, $stageEffective );
145 }
while ( $stage === self::ALL && self::$preSendUpdates );
157 $existingUpdate =
$queue[$class];
158 $existingUpdate->merge( $update );
181 $services = MediaWikiServices::getInstance();
182 $stats =
$services->getStatsdDataFactory();
183 $lbFactory =
$services->getDBLoadBalancerFactory();
184 $method = RequestContext::getMain()->getRequest()->getMethod();
186 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
189 $reportableError =
null;
198 $updatesByType = [
'data' => [],
'generic' => [] ];
199 foreach ( $updates as $du ) {
201 $du->setTransactionTicket( $ticket );
202 $updatesByType[
'data'][] =
$du;
204 $updatesByType[
'generic'][] =
$du;
208 ?
get_class( $du ) .
'-' . $du->getOrigin()
210 $stats->increment(
'deferred_updates.' . $method .
'.' . $name );
214 foreach ( $updatesByType as $updatesForType ) {
215 foreach ( $updatesForType as $update ) {
216 self::$executeContext = [
'stage' => $stage,
'subqueue' => [] ];
219 $guiError = self::runUpdate( $update, $lbFactory, $mode, $stage );
220 $reportableError = $reportableError ?:
$guiError;
222 while ( self::$executeContext[
'subqueue'] ) {
223 $subUpdate = reset( self::$executeContext[
'subqueue'] );
224 $firstKey =
key( self::$executeContext[
'subqueue'] );
225 unset( self::$executeContext[
'subqueue'][$firstKey] );
228 $subUpdate->setTransactionTicket( $ticket );
231 $guiError = self::runUpdate( $subUpdate, $lbFactory, $mode, $stage );
232 $reportableError = $reportableError ?:
$guiError;
238 self::$executeContext =
null;
246 if ( $reportableError ) {
265 $spec = $update->getAsJobSpecification();
266 $domain = $spec[
'domain'] ?? $spec[
'wiki'];
267 JobQueueGroup::singleton( $domain )->push( $spec[
'job'] );
272 $fnameTrxOwner =
get_class( $update ) .
'::doUpdate';
277 }
catch ( Exception
$e ) {
282 MWExceptionHandler::rollbackMasterChangesAndLog(
$e );
286 if ( defined(
'MW_PHPUNIT_TEST' ) ) {
307 if ( self::$executeContext ) {
312 if ( !self::areDatabaseTransactionsActive() ) {
313 self::doUpdates( $mode );
317 if ( self::pendingUpdatesCount() >= self::BIG_QUEUE_SIZE ) {
320 self::$preSendUpdates = self::enqueueUpdates( self::$preSendUpdates );
321 self::$postSendUpdates = self::enqueueUpdates( self::$postSendUpdates );
324 return !self::pendingUpdatesCount();
336 foreach ( $updates as $update ) {
338 $spec = $update->getAsJobSpecification();
339 $domain = $spec[
'domain'] ?? $spec[
'wiki'];
340 JobQueueGroup::singleton( $domain )->push( $spec[
'job'] );
354 return count( self::$preSendUpdates ) + count( self::$postSendUpdates );
364 if ( $stage === self::ALL || $stage === self::PRESEND ) {
365 $updates =
array_merge( $updates, self::$preSendUpdates );
367 if ( $stage === self::ALL || $stage === self::POSTSEND ) {
368 $updates =
array_merge( $updates, self::$postSendUpdates );
378 self::$preSendUpdates = [];
379 self::$postSendUpdates = [];
386 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
387 if ( $lbFactory->hasTransactionRound() || !$lbFactory->isReadyForRoundOperations() ) {
392 $lbFactory->forEachLB(
function (
LoadBalancer $lb ) use ( &$connsBusy ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
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
returning false will NOT prevent logging $e
Callback wrapper that has an originating method.
Interface that deferrable updates should implement.
Interface that marks a DataUpdate as enqueuable via the JobQueue.
Interface that deferrable updates can implement to signal that updates can be combined.
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))