73 if ( !isset( self::$instances[
$wiki] ) ) {
77 return self::$instances[
$wiki];
86 self::$instances = [];
105 if ( $this->readOnlyReason !==
false ) {
122 public function push( $jobs ) {
125 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
126 if ( !count( $jobs ) ) {
133 foreach ( $jobs
as $job ) {
134 $jobsByType[
$job->getType()][] =
$job;
137 foreach ( $jobsByType
as $type => $jobs ) {
141 if ( $this->
cache->has(
'queues-ready',
'list' ) ) {
142 $list = $this->
cache->get(
'queues-ready',
'list' );
143 if ( count( array_diff( array_keys( $jobsByType ), $list ) ) ) {
144 $this->
cache->clear(
'queues-ready' );
148 $cache = ObjectCache::getLocalClusterInstance();
150 $cache->makeGlobalKey(
'jobqueue', $this->wiki,
'hasjobs', self::TYPE_ANY ),
156 $cache->makeGlobalKey(
'jobqueue', $this->wiki,
'hasjobs', self::TYPE_DEFAULT ),
175 if ( PHP_SAPI ===
'cli' ) {
176 $this->
push( $jobs );
180 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
185 $this->bufferedJobs = array_merge( $this->bufferedJobs, $jobs );
195 foreach ( self::$instances
as $group ) {
197 $group->push( $group->bufferedJobs );
198 $group->bufferedJobs = [];
199 }
catch ( Exception
$e ) {
201 MWExceptionHandler::logException(
$e );
217 public function pop( $qtype = self::TYPE_DEFAULT,
$flags = 0,
array $blacklist = [] ) {
220 if ( is_string( $qtype ) ) {
221 if ( !in_array( $qtype, $blacklist ) ) {
222 $job = $this->
get( $qtype )->
pop();
225 if (
$flags & self::USE_CACHE ) {
226 if ( !$this->
cache->has(
'queues-ready',
'list', self::PROC_CACHE_TTL ) ) {
229 $types = $this->
cache->get(
'queues-ready',
'list' );
234 if ( $qtype == self::TYPE_DEFAULT ) {
238 $types = array_diff( $types, $blacklist );
246 $this->
cache->clear(
'queues-ready' );
308 return array_diff( $this->
getQueueTypes(), $wgJobTypesExcludedFromDefaultQueue );
319 $cache = ObjectCache::getLocalClusterInstance();
320 $key =
$cache->makeGlobalKey(
'jobqueue', $this->
wiki,
'hasjobs',
$type );
325 if (
$type == self::TYPE_DEFAULT ) {
328 $value = count( $queues ) ?
'true' :
'false';
332 return (
$value ===
'true' );
343 $nonEmpty = $info[
'queue']->getSiblingQueuesWithJobs( $this->
getQueueTypes() );
344 if ( is_array( $nonEmpty ) ) {
345 $types = array_merge( $types, $nonEmpty );
347 foreach ( $info[
'types']
as $type ) {
348 if ( !$this->
get( $type )->isEmpty() ) {
366 $sizes = $info[
'queue']->getSiblingQueueSizes( $this->
getQueueTypes() );
367 if ( is_array( $sizes ) ) {
368 $sizeMap = $sizeMap + $sizes;
370 foreach ( $info[
'types']
as $type ) {
371 $sizeMap[
$type] = $this->
get(
$type )->getSize();
385 if ( $this->coalescedQueues ===
null ) {
386 $this->coalescedQueues = [];
389 [
'wiki' => $this->
wiki,
'type' =>
'null' ] + $conf );
390 $loc =
$queue->getCoalesceLocationInternal();
391 if ( !isset( $this->coalescedQueues[$loc] ) ) {
392 $this->coalescedQueues[$loc][
'queue'] =
$queue;
393 $this->coalescedQueues[$loc][
'types'] = [];
395 if (
$type ===
'default' ) {
396 $this->coalescedQueues[$loc][
'types'] = array_merge(
397 $this->coalescedQueues[$loc][
'types'],
401 $this->coalescedQueues[$loc][
'types'][] =
$type;
419 $cache = ObjectCache::getMainWANInstance();
422 $cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
428 [
'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
440 foreach ( $jobs
as $job ) {
442 throw new InvalidArgumentException(
"Expected IJobSpecification objects" );
448 $n = count( $this->bufferedJobs );
450 $type = implode(
', ', array_unique( array_map(
'get_class', $this->bufferedJobs ) ) );
451 trigger_error( __METHOD__ .
": $n buffered job(s) of type(s) $type never inserted." );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgJobTypeConf
Map of job types to configuration arrays.
$wgJobTypesExcludedFromDefaultQueue
Jobs that must be explicitly requested, i.e.
$wgConf
wgConf hold the site configuration.
wfConfiguredReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Class to handle enqueueing of background jobs.
getCachedConfigVar( $name)
push( $jobs)
Insert jobs into the respective queues of which they belong.
getQueueSizes()
Get the size of the queus for a list of job types.
ack(Job $job)
Acknowledge that a job was completed.
static pushLazyJobs()
Push all jobs buffered via lazyPush() into their respective queues.
waitForBackups()
Wait for any replica DBs or backup queue servers to catch up.
deduplicateRootJob(Job $job)
Register the "root job" of a given job into the queue for de-duplication.
array $coalescedQueues
Map of (bucket => (queue => JobQueue, types => list of types)
__construct( $wiki, $readOnlyReason)
string bool $readOnlyReason
Read only rationale (or false if r/w)
getDefaultQueueTypes()
Get the list of default queue types.
lazyPush( $jobs)
Buffer jobs for insertion via push() or call it now if in CLI mode.
pop( $qtype=self::TYPE_DEFAULT, $flags=0, array $blacklist=[])
Pop a job off one of the job queues.
static destroySingletons()
Destroy the singleton instances.
queuesHaveJobs( $type=self::TYPE_ANY)
Check if there are any queues with jobs (this is cached)
static JobQueueGroup[] $instances
static singleton( $wiki=false)
getQueuesWithJobs()
Get the list of job types that have non-empty queues.
assertValidJobs(array $jobs)
getQueueTypes()
Get the list of queue types.
static factory(array $params)
Get a job queue object of the specified type.
Class to both describe a background job and handle jobs.
Handles per process caching of items.
get( $key, $prop)
Get a property field for a cache entry.
set( $key, $prop, $value)
Set a property field for a cache entry.
when a variable name is used in a it is silently declared as a new local masking the global
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
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
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
you have access to all of the normal MediaWiki so you can get a DB use the cache
if(count( $args)< 1) $job