MediaWiki  master
DeferredUpdatesScope Class Reference

DeferredUpdates helper class for managing DeferrableUpdate::doUpdate() nesting levels caused by nested calls to DeferredUpdates::doUpdates() More...

Collaboration diagram for DeferredUpdatesScope:

Public Member Functions

 addUpdate (DeferrableUpdate $update, $stage)
 Enqueue a deferred update within this scope using the specified "defer until" time. More...
 
 clearPendingUpdates ()
 Cancel all pending updates within this scope. More...
 
 consumeMatchingUpdates ( $stage, $class, callable $callback)
 Remove pending updates of the specified stage/class and pass them to a callback. More...
 
 getActiveUpdate ()
 Get the deferred update that owns this scope (root scope has none) More...
 
 getPendingUpdates ( $stage)
 Get pending updates within this scope with the given "defer until" stage. More...
 
 pendingUpdatesCount ()
 Get the number of pending updates within this scope. More...
 
 processUpdates ( $stage, callable $callback)
 Iteratively, reassign unready pending updates to the parent scope (if applicable) and process the ready pending updates in stage-order with the callback, repeating the process until there is nothing left to do. More...
 

Static Public Member Functions

static newChildScope ( $activeStage, DeferrableUpdate $update, DeferredUpdatesScope $parentScope)
 
static newRootScope ()
 

Private Member Functions

 __construct ( $activeStage, ?DeferrableUpdate $update, ?DeferredUpdatesScope $parentScope)
 
 processStageQueue ( $stage, $activeStage, callable $callback)
 
 upmergeUnreadyUpdates ( $activeStage)
 If this is a child scope, then reassign unready pending updates to the parent scope: More...
 

Private Attributes

int null $activeStage
 Active processing stage in DeferredUpdates::STAGES (if any) More...
 
DeferrableUpdate null $activeUpdate
 Deferred update that owns this scope (root scope has none) More...
 
DeferredUpdatesScope null $parentScope
 Parent scope (root scope as none) More...
 
DeferrableUpdate[][] $queueByStage
 Stage-ordered (stage => merge class or position => update) map. More...
 

Detailed Description

DeferredUpdates helper class for managing DeferrableUpdate::doUpdate() nesting levels caused by nested calls to DeferredUpdates::doUpdates()

See also
DeferredUpdates
DeferredUpdatesScopeStack
Access: internal
For use by DeferredUpdates and DeferredUpdatesScopeStack only
Since
1.36

Definition at line 30 of file DeferredUpdatesScope.php.

Constructor & Destructor Documentation

◆ __construct()

DeferredUpdatesScope::__construct (   $activeStage,
?DeferrableUpdate  $update,
?DeferredUpdatesScope  $parentScope 
)
private
Parameters
int | null$activeStageOne of DeferredUpdates::STAGES or null
DeferrableUpdate | null$update
DeferredUpdatesScope | null$parentScope

Definition at line 45 of file DeferredUpdatesScope.php.

References $activeStage, and $parentScope.

Member Function Documentation

◆ addUpdate()

DeferredUpdatesScope::addUpdate ( DeferrableUpdate  $update,
  $stage 
)

Enqueue a deferred update within this scope using the specified "defer until" time.

Parameters
DeferrableUpdate$update
int$stageOne of DeferredUpdates::STAGES

Definition at line 92 of file DeferredUpdatesScope.php.

References $queue.

◆ clearPendingUpdates()

DeferredUpdatesScope::clearPendingUpdates ( )

Cancel all pending updates within this scope.

Definition at line 146 of file DeferredUpdatesScope.php.

◆ consumeMatchingUpdates()

DeferredUpdatesScope::consumeMatchingUpdates (   $stage,
  $class,
callable  $callback 
)

Remove pending updates of the specified stage/class and pass them to a callback.

Parameters
int$stageOne of DeferredUpdates::STAGES or DeferredUpdates::ALL
string$classOnly take updates of this fully qualified class/interface name
callable$callbackCallback that takes DeferrableUpdate

Definition at line 157 of file DeferredUpdatesScope.php.

References $queue.

◆ getActiveUpdate()

DeferredUpdatesScope::getActiveUpdate ( )

Get the deferred update that owns this scope (root scope has none)

Returns
DeferrableUpdate|null

Definition at line 82 of file DeferredUpdatesScope.php.

References $activeUpdate.

◆ getPendingUpdates()

DeferredUpdatesScope::getPendingUpdates (   $stage)

Get pending updates within this scope with the given "defer until" stage.

Parameters
int$stageOne of DeferredUpdates::STAGES or DeferredUpdates::ALL
Returns
DeferrableUpdate[]

Definition at line 132 of file DeferredUpdatesScope.php.

References $queue.

◆ newChildScope()

static DeferredUpdatesScope::newChildScope (   $activeStage,
DeferrableUpdate  $update,
DeferredUpdatesScope  $parentScope 
)
static
Parameters
int$activeStageThe in-progress stage; one of DeferredUpdates::STAGES
DeferrableUpdate$updateThe deferred update that owns this scope
DeferredUpdatesScope$parentScopeThe parent scope of this scope
Returns
DeferredUpdatesScope Scope for the case of an in-progress deferred update

Definition at line 69 of file DeferredUpdatesScope.php.

References $activeStage, and $parentScope.

Referenced by DeferredUpdatesScopeStack\descend().

◆ newRootScope()

static DeferredUpdatesScope::newRootScope ( )
static
Returns
DeferredUpdatesScope Scope for the case of no in-progress deferred update

Definition at line 59 of file DeferredUpdatesScope.php.

Referenced by DeferredUpdatesScopeStack\__construct().

◆ pendingUpdatesCount()

DeferredUpdatesScope::pendingUpdatesCount ( )

Get the number of pending updates within this scope.

Returns
int

Definition at line 122 of file DeferredUpdatesScope.php.

◆ processStageQueue()

DeferredUpdatesScope::processStageQueue (   $stage,
  $activeStage,
callable  $callback 
)
private
Parameters
int$stageOne of DeferredUpdates::STAGES
int$activeStageOne of DeferredUpdates::STAGES
callable$callbackProcessing function with arguments (update, effective stage)
Returns
int Number of updates processed

Definition at line 237 of file DeferredUpdatesScope.php.

References $activeStage.

Referenced by processUpdates().

◆ processUpdates()

DeferredUpdatesScope::processUpdates (   $stage,
callable  $callback 
)

Iteratively, reassign unready pending updates to the parent scope (if applicable) and process the ready pending updates in stage-order with the callback, repeating the process until there is nothing left to do.

Parameters
int$stageOne of DeferredUpdates::STAGES or DeferredUpdates::ALL
callable$callbackProcessing function with arguments (update, effective stage)

Definition at line 184 of file DeferredUpdatesScope.php.

References $activeStage, processStageQueue(), and upmergeUnreadyUpdates().

◆ upmergeUnreadyUpdates()

DeferredUpdatesScope::upmergeUnreadyUpdates (   $activeStage)
private

If this is a child scope, then reassign unready pending updates to the parent scope:

  • MergeableUpdate instances will be reassigned to the parent scope on account of their de-duplication/melding semantics. They are normally only processed in the root scope.
  • DeferrableUpdate instances with a "defer until" stage later than the specified stage will be reassigned to the parent scope since they are not ready.
Parameters
int$activeStageOne of DeferredUpdates::STAGES
Returns
int Number of updates moved

Definition at line 211 of file DeferredUpdatesScope.php.

References $activeStage, and $queue.

Referenced by processUpdates().

Member Data Documentation

◆ $activeStage

int null DeferredUpdatesScope::$activeStage
private

Active processing stage in DeferredUpdates::STAGES (if any)

Definition at line 36 of file DeferredUpdatesScope.php.

Referenced by __construct(), newChildScope(), processStageQueue(), processUpdates(), and upmergeUnreadyUpdates().

◆ $activeUpdate

DeferrableUpdate null DeferredUpdatesScope::$activeUpdate
private

Deferred update that owns this scope (root scope has none)

Definition at line 34 of file DeferredUpdatesScope.php.

Referenced by getActiveUpdate().

◆ $parentScope

DeferredUpdatesScope null DeferredUpdatesScope::$parentScope
private

Parent scope (root scope as none)

Definition at line 32 of file DeferredUpdatesScope.php.

Referenced by __construct(), and newChildScope().

◆ $queueByStage

DeferrableUpdate [][] DeferredUpdatesScope::$queueByStage
private

Stage-ordered (stage => merge class or position => update) map.

Definition at line 38 of file DeferredUpdatesScope.php.


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