60 $this->
type = $params[
'type'];
61 $this->claimTTL =
$params[
'claimTTL'] ?? 0;
62 $this->maxTries =
$params[
'maxTries'] ?? 3;
64 $this->order =
$params[
'order'];
69 throw new MWException( __CLASS__ .
" does not support '{$this->order}' order." );
73 $this->readOnlyReason =
$params[
'readOnlyReason'] ??
false;
106 if ( !class_exists( $class ) ) {
107 throw new MWException(
"Invalid job queue class '$class'." );
110 if ( !( $obj instanceof
self ) ) {
111 throw new MWException(
"Class '$class' is not a " . __CLASS__ .
" class." );
300 final public function push( $jobs, $flags = 0 ) {
301 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
318 if ( !count( $jobs ) ) {
322 foreach ( $jobs
as $job ) {
323 if (
$job->getType() !== $this->type ) {
325 "Got '{$job->getType()}' job; expected a '{$this->type}' job." );
326 } elseif (
$job->getReleaseTimestamp() && !$this->supportsDelayedJobs() ) {
328 "Got delayed '{$job->getType()}' job; delays are not supported." );
333 $this->aggr->notifyQueueNonEmpty( $this->
wiki, $this->
type );
335 foreach ( $jobs
as $job ) {
336 if (
$job->isRootJob() ) {
357 final public function pop() {
362 throw new MWException(
"Cannot pop '{$this->type}' job off foreign wiki queue." );
365 throw new MWException(
"Unrecognized job type '{$this->type}'." );
371 $this->aggr->notifyQueueEmpty( $this->
wiki, $this->type );
380 }
catch ( Exception
$e ) {
391 abstract protected function doPop();
405 if ( $job->
getType() !== $this->type ) {
406 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
409 $this->
doAck( $job );
451 if ( $job->
getType() !== $this->type ) {
452 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
465 if ( !
$job->hasRootJobParams() ) {
466 throw new MWException(
"Cannot register root job; missing parameters." );
476 $timestamp = $this->dupCache->get( $key );
477 if ( $timestamp && $timestamp >=
$params[
'rootJobTimestamp'] ) {
493 if (
$job->getType() !== $this->type ) {
494 throw new MWException(
"Got '{$job->getType()}' job; expected '{$this->type}'." );
507 if ( !
$job->hasRootJobParams() ) {
514 $timestamp = $this->dupCache->get( $key );
517 return ( $timestamp && $timestamp >
$params[
'rootJobTimestamp'] );
537 final public function delete() {
548 throw new MWException(
"This method is not implemented." );
605 return new ArrayIterator( [] );
619 return new ArrayIterator( [] );
630 return new ArrayIterator( [] );
692 if ( $this->readOnlyReason !==
false ) {
708 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
710 $stats->updateCount(
"jobqueue.{$key}.all", $delta );
711 $stats->updateCount(
"jobqueue.{$key}.{$type}", $delta );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgJobClasses
Maps jobs to their handlers; extensions can add to this to provide custom jobs.
wfSplitWikiID( $wiki)
Split a wiki ID into DB name and table prefix.
wfGetCache( $cacheType)
Get a specific cache object.
wfForeignMemcKey( $db, $prefix,... $args)
Make a cache key for a foreign DB.
Class representing a cache/ephemeral data store.
static newFromJob(Job $job)
Get a duplicate no-op version of a job.
Class to handle tracking information about all queues.
Class to handle enqueueing and running of background jobs.
isEmpty()
Quickly check if the queue has no available (unacquired, non-delayed) jobs.
string $order
Job priority for pop()
__construct(array $params)
getAbandonedCount()
Get the number of acquired jobs that can no longer be attempted.
waitForBackups()
Wait for any replica DBs or backup servers to catch up.
isRootJobOldDuplicate(Job $job)
Check if the "root" job of a given job has been superseded by a newer one.
static incrStats( $key, $type, $delta=1)
Call wfIncrStats() for the queue overall and for the queue type.
push( $jobs, $flags=0)
Push one or more jobs into the queue.
pop()
Pop a job off of the queue.
int $claimTTL
Time to live in seconds.
doDeduplicateRootJob(IJobSpecification $job)
getCoalesceLocationInternal()
Do not use this function outside of JobQueue/JobQueueGroup.
batchPush(array $jobs, $flags=0)
Push a batch of jobs into the queue.
doGetSiblingQueueSizes(array $types)
supportsDelayedJobs()
Find out if delayed jobs are supported for configuration validation.
getSiblingQueueSizes(array $types)
Check the size of each of the given queues.
int $maxTries
Maximum number of times to try a job.
getAllQueuedJobs()
Get an iterator to traverse over all available jobs in this queue.
static factory(array $params)
Get a job queue object of the specified type.
getAllAbandonedJobs()
Get an iterator to traverse over all abandoned jobs in this queue.
doBatchPush(array $jobs, $flags)
ack(Job $job)
Acknowledge that a job was completed.
getAllAcquiredJobs()
Get an iterator to traverse over all claimed jobs in this queue.
string bool $readOnlyReason
Read only rationale (or false if r/w)
doGetSiblingQueuesWithJobs(array $types)
deduplicateRootJob(IJobSpecification $job)
Register the "root job" of a given job into the queue for de-duplication.
getSize()
Get the number of available (unacquired, non-delayed) jobs in the queue.
getAcquiredCount()
Get the number of acquired jobs (these are temporarily out of the queue).
doIsRootJobOldDuplicate(Job $job)
flushCaches()
Clear any process and persistent caches.
getAllDelayedJobs()
Get an iterator to traverse over all delayed jobs in this queue.
supportedOrders()
Get the allowed queue orders for configuration validation.
getSiblingQueuesWithJobs(array $types)
Check whether each of the given queues are empty.
getRootJobCacheKey( $signature)
optimalOrder()
Get the default queue order to use if configuration does not specify one.
getDelayedCount()
Get the number of delayed jobs (these are temporarily out of the queue).
Class to both describe a background job and handle jobs.
static isCurrentWikiDbDomain( $domain)
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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
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
Job queue task description interface.
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
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))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
if(count( $args)< 1) $job