MediaWiki REL1_27
DeferredUpdates Class Reference

Class for managing the deferred updates. More...

Collaboration diagram for DeferredUpdates:

Static Public Member Functions

static addCallableUpdate ( $callable, $type=self::POSTSEND)
 Add a callable update.
 
static addUpdate (DeferrableUpdate $update, $type=self::POSTSEND)
 Add an update to the deferred list.
 
static clearPendingUpdates ()
 Clear all pending updates without performing them.
 
static doUpdates ( $mode='run', $type=self::ALL)
 Do any deferred updates and clear the list.
 
static execute (array &$queue, $mode)
 

Public Attributes

const ALL = 0
 
const POSTSEND = 2
 
const PRESEND = 1
 

Static Private Member Functions

static push (array &$queue, DeferrableUpdate $update)
 

Static Private Attributes

static DeferrableUpdate[] $postSendUpdates = []
 Updates to be deferred until after request end.
 
static DeferrableUpdate[] $preSendUpdates = []
 Updates to be deferred until before request end.
 

Detailed Description

Class for managing the deferred updates.

In web request mode, deferred updates can be run at the end of the request, either before or after the HTTP response has been sent. In either case, they run after the DB commit step. If an update runs after the response is sent, it will not block clients. If sent before, it will run synchronously. If such an update works via queueing, it will be more likely to complete by the time the client makes their next request after this one.

In CLI mode, updates are only deferred until the current wiki has no DB write transaction active within this request.

When updates are deferred, they use a FIFO queue (one for pre-send and one for post-send).

Since
1.19

Definition at line 39 of file DeferredUpdates.php.

Member Function Documentation

◆ addCallableUpdate()

static DeferredUpdates::addCallableUpdate (   $callable,
  $type = self::POSTSEND 
)
static

Add a callable update.

In a lot of cases, we just need a callback/closure, defining a new DeferrableUpdate object is not necessary

See also
MWCallableUpdate::__construct()
Parameters
callable$callable
integer$typeDeferredUpdates constant (PRESEND or POSTSEND) (since 1.27)

Definition at line 72 of file DeferredUpdates.php.

References $type.

Referenced by MediaWiki\Logger\Monolog\BufferHandler\handle().

◆ addUpdate()

static DeferredUpdates::addUpdate ( DeferrableUpdate  $update,
  $type = self::POSTSEND 
)
static

Add an update to the deferred list.

Parameters
DeferrableUpdate$updateSome object that implements doUpdate()
integer$typeDeferredUpdates constant (PRESEND or POSTSEND) (since 1.27)

Definition at line 55 of file DeferredUpdates.php.

References $type.

◆ clearPendingUpdates()

static DeferredUpdates::clearPendingUpdates ( )
static

Clear all pending updates without performing them.

Generally, you don't want or need to call this. Unit tests need it though.

Definition at line 173 of file DeferredUpdates.php.

◆ doUpdates()

static DeferredUpdates::doUpdates (   $mode = 'run',
  $type = self::ALL 
)
static

Do any deferred updates and clear the list.

Parameters
string$modeUse "enqueue" to use the job queue when possible [Default: "run"]
integer$typeDeferredUpdates constant (PRESEND, POSTSEND, or ALL) (since 1.27)

Definition at line 82 of file DeferredUpdates.php.

References $type, and execute().

Referenced by push().

◆ execute()

static DeferredUpdates::execute ( array $queue,
  $mode 
)
static

Definition at line 128 of file DeferredUpdates.php.

References $e, $queue, as, DataUpdate\runUpdates(), and wfGetLBFactory().

◆ push()

static DeferredUpdates::push ( array $queue,
DeferrableUpdate  $update 
)
staticprivate

Definition at line 92 of file DeferredUpdates.php.

References $queue, $wgCommandLineMode, doUpdates(), global, use, and wfGetLB().

Member Data Documentation

◆ $postSendUpdates

DeferrableUpdate [] DeferredUpdates::$postSendUpdates = []
staticprivate

Updates to be deferred until after request end.

Definition at line 43 of file DeferredUpdates.php.

◆ $preSendUpdates

DeferrableUpdate [] DeferredUpdates::$preSendUpdates = []
staticprivate

Updates to be deferred until before request end.

Definition at line 41 of file DeferredUpdates.php.

◆ ALL

const DeferredUpdates::ALL = 0

Definition at line 45 of file DeferredUpdates.php.

◆ POSTSEND

const DeferredUpdates::POSTSEND = 2

Definition at line 47 of file DeferredUpdates.php.

◆ PRESEND

const DeferredUpdates::PRESEND = 1

Definition at line 46 of file DeferredUpdates.php.


The documentation for this class was generated from the following file: