MediaWiki
1.28.0
|
Class for managing the deferred updates. More...
Static Public Member Functions | |
static | addCallableUpdate ($callable, $stage=self::POSTSEND, IDatabase $dbw=null) |
Add a callable update. More... | |
static | addUpdate (DeferrableUpdate $update, $stage=self::POSTSEND) |
Add an update to the deferred list to be run later by execute() More... | |
static | clearPendingUpdates () |
Clear all pending updates without performing them. More... | |
static | doUpdates ($mode= 'run', $stage=self::ALL) |
Do any deferred updates and clear the list. More... | |
static | pendingUpdatesCount () |
static | setImmediateMode ($value) |
static | tryOpportunisticExecute ($mode= 'run') |
Run all deferred updates immediately if there are no DB writes active. More... | |
Public Attributes | |
const | ALL = 0 |
const | BIG_QUEUE_SIZE = 100 |
const | POSTSEND = 2 |
const | PRESEND = 1 |
Static Protected Member Functions | |
static | execute (array &$queue, $mode, $stage) |
Immediately run/queue a list of updates. More... | |
Static Private Member Functions | |
static | enqueueUpdates (array $updates) |
Enqueue a job for each EnqueueableDataUpdate item and return the other items. More... | |
static | getBusyDbConnections () |
static | push (array &$queue, DeferrableUpdate $update) |
static | runUpdate (DeferrableUpdate $update, LBFactory $lbFactory, $stage) |
Static Private Attributes | |
static array null | $executeContext |
Information about the current execute() call or null if not running. More... | |
static bool | $immediateMode = false |
Whether to just run updates in addUpdate() More... | |
static DeferrableUpdate[] | $postSendUpdates = [] |
Updates to be deferred until after request end. More... | |
static DeferrableUpdate[] | $preSendUpdates = [] |
Updates to be deferred until before request end. More... | |
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. These two modes are defined via PRESEND and POSTSEND constants, the latter being the default for addUpdate() and addCallableUpdate().
Updates that work through this system will be more likely to complete by the time the client makes their next request after this one than with the JobQueue system.
In CLI mode, updates run immediately if no DB writes are pending. Otherwise, they run when:
When updates are deferred, they go into one two FIFO "top-queues" (one for pre-send and one for post-send). Updates enqueued during doUpdate() of a "top" update go into the "sub-queue" for that update. After that method finishes, the sub-queue is run until drained. This continues for each top-queue job until the entire top queue is drained. This happens for the pre-send top-queue, and later on, the post-send top-queue, in execute().
Definition at line 50 of file DeferredUpdates.php.
|
static |
Add a callable update.
In a lot of cases, we just need a callback/closure, defining a new DeferrableUpdate object is not necessary
callable | $callable | |
integer | $stage | DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27) |
IDatabase | null | $dbw | Abort if this DB is rolled back optional |
Definition at line 113 of file DeferredUpdates.php.
References wfGetCaller().
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider\beginPrimaryAuthentication(), SpecialEditWatchlist\cleanupWatchlist(), User\clearNotification(), FileBackendMultiWrite\doDirectoryOp(), WikiPage\doEditContent(), FileBackendMultiWrite\doOperationsInternal(), FileBackendMultiWrite\doQuickOperationsInternal(), SiteStatsUpdate\doUpdate(), EditPage\edit(), ApiClearHasMsg\execute(), MovePageForm\execute(), CategoryViewer\getCountMessage(), MediaWiki\Logger\Monolog\BufferHandler\handle(), Category\initialize(), WikiPage\insertRedirect(), LocalFile\maybeUpgradeRow(), RecentChange\notifyEdit(), RecentChange\notifyNew(), WikiPage\onArticleEdit(), ManualLogEntry\publish(), MediaWiki\Session\SessionBackend\save(), SpecialSearch\saveNamespaces(), Pingback\schedulePingback(), RevDelList\setVisibility(), DeferredUpdatesTest\testDoUpdatesCLI(), DeferredUpdatesTest\testDoUpdatesWeb(), WatchedItemStore\updateNotificationTimestamp(), and EditPage\updateWatchlist().
|
static |
Add an update to the deferred list to be run later by execute()
In CLI mode, callback magic will also be used to run updates when safe
DeferrableUpdate | $update | Some object that implements doUpdate() |
integer | $stage | DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27) |
Definition at line 75 of file DeferredUpdates.php.
References $wgCommandLineMode, and global.
Referenced by MediaWiki\Auth\AuthManager\autoCreateUser(), User\clearAllNotifications(), MediaWiki\Auth\AuthManager\continueAccountCreation(), LocalFile\delete(), LocalFile\deleteOld(), WikiPage\doCreate(), WikiPage\doDeleteUpdates(), WikiPage\doEditUpdates(), WikiPage\doModify(), RevDelFileList\doPostCommitUpdates(), WikiFilePage\doPurge(), WikiPage\doPurge(), ApiPurge\execute(), LocalFileRestoreBatch\execute(), WikiImporter\finishImportPage(), RefreshLinks\fixLinksFromArticle(), Title\invalidateCache(), LinksUpdate\invalidateProperties(), NamespaceConflictChecker\mergePage(), MovePage\move(), LocalFile\move(), WikiPage\onArticleDelete(), WikiPage\onArticleEdit(), LocalFile\purgeCache(), File\purgeEverything(), Block\purgeExpired(), Title\purgeExpiredRestrictions(), LocalFile\purgeOldThumbnails(), Title\purgeSquid(), LocalFile\purgeThumbnails(), LocalFile\recordUpload2(), CdnCacheUpdateTest\testPurgeMergeWeb(), Title\touchLinks(), and PageArchive\undeleteRevisions().
|
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 341 of file DeferredUpdates.php.
Referenced by UploadFromUrlTestSuite\setUp(), and MediaWikiTestCase\setUp().
|
static |
Do any deferred updates and clear the list.
string | $mode | Use "enqueue" to use the job queue when possible [Default: "run"] |
integer | $stage | DeferredUpdates constant (PRESEND, POSTSEND, or ALL) (since 1.27) |
Definition at line 125 of file DeferredUpdates.php.
References execute().
Referenced by JobRunner\executeJob(), NamespaceConflictChecker\mergePage(), MediaWiki\preOutputCommit(), MediaWiki\restInPeace(), FileBackendTest\testAsyncWrites(), DeferredUpdatesTest\testDoUpdatesCLI(), DeferredUpdatesTest\testDoUpdatesWeb(), and BagOStuffTest\testReportDupes().
|
staticprivate |
Enqueue a job for each EnqueueableDataUpdate item and return the other items.
DeferrableUpdate[] | $updates A list of deferred update instances |
Definition at line 314 of file DeferredUpdates.php.
References as, and JobQueueGroup\singleton().
|
staticprotected |
Immediately run/queue a list of updates.
DeferrableUpdate[] | &$queue List of DeferrableUpdate objects | |
string | $mode | Use "enqueue" to use the job queue when possible |
integer | $stage | Class constant (PRESEND, POSTSEND) (since 1.28) |
ErrorPageError | Happens on top-level calls |
Exception | Happens on second-level calls |
Definition at line 173 of file DeferredUpdates.php.
References $e, $lbFactory, $name, $queue, $services, as, RequestContext\getMain(), key, and MWExceptionHandler\rollbackMasterChangesAndLog().
|
staticprivate |
Definition at line 349 of file DeferredUpdates.php.
References $lbFactory, IDatabase\explicitTrxActive(), LoadBalancer\forEachOpenMasterConnection(), use, and IDatabase\writesOrCallbacksPending().
|
static |
Definition at line 333 of file DeferredUpdates.php.
Referenced by EditPageTest\testCreatePageTrx(), and DeferredUpdatesTest\testDoUpdatesWeb().
|
staticprivate |
DeferrableUpdate[] | $queue | |
DeferrableUpdate | $update |
Definition at line 149 of file DeferredUpdates.php.
|
staticprivate |
DeferrableUpdate | $update | |
LBFactory | $lbFactory | |
integer | $stage |
Definition at line 258 of file DeferredUpdates.php.
References $e, LBFactory\beginMasterChanges(), LBFactory\commitMasterChanges(), DeferrableUpdate\doUpdate(), and MWExceptionHandler\rollbackMasterChangesAndLog().
|
static |
bool | $value | Whether to just immediately run updates in addUpdate() |
Definition at line 141 of file DeferredUpdates.php.
References $value.
Referenced by MediaWiki\restInPeace().
|
static |
Run all deferred updates immediately if there are no DB writes active.
If $mode is 'run' but there are busy databates, EnqueueableDataUpdate tasks will be enqueued anyway for the sake of progress.
string | $mode | Use "enqueue" to use the job queue when possible |
Definition at line 286 of file DeferredUpdates.php.
Referenced by Maintenance\setLBFactoryTriggers().
|
staticprivate |
Information about the current execute() call or null if not running.
Definition at line 65 of file DeferredUpdates.php.
|
staticprivate |
Whether to just run updates in addUpdate()
Definition at line 56 of file DeferredUpdates.php.
|
staticprivate |
Updates to be deferred until after request end.
Definition at line 54 of file DeferredUpdates.php.
|
staticprivate |
Updates to be deferred until before request end.
Definition at line 52 of file DeferredUpdates.php.
const DeferredUpdates::ALL = 0 |
Definition at line 58 of file DeferredUpdates.php.
const DeferredUpdates::BIG_QUEUE_SIZE = 100 |
Definition at line 62 of file DeferredUpdates.php.
const DeferredUpdates::POSTSEND = 2 |
Definition at line 60 of file DeferredUpdates.php.
Referenced by WikiPage\insertRedirect(), RecentChange\notifyEdit(), RecentChange\notifyNew(), ManualLogEntry\publish(), DeferredUpdatesTest\testDoUpdatesWeb(), and WatchedItemStore\updateNotificationTimestamp().
const DeferredUpdates::PRESEND = 1 |
Definition at line 59 of file DeferredUpdates.php.
Referenced by LocalFile\delete(), LocalFile\deleteOld(), WikiPage\doCreate(), WikiPage\doModify(), RevDelFileList\doPostCommitUpdates(), WikiPage\doPurge(), ApiPurge\execute(), Title\invalidateCache(), LocalFile\move(), MediaWiki\preOutputCommit(), LocalFile\purgeCache(), LocalFile\purgeOldThumbnails(), Title\purgeSquid(), LocalFile\purgeThumbnails(), LocalFile\recordUpload2(), RevDelList\setVisibility(), and DeferredUpdatesTest\testDoUpdatesWeb().