Go to the documentation of this file.
66 if ( !isset( self::$instances[
$wiki] ) ) {
70 return self::$instances[
$wiki];
79 self::$instances =
array();
88 public function get(
$type ) {
92 if ( isset( $wgJobTypeConf[
$type] ) ) {
93 $conf = $conf + $wgJobTypeConf[
$type];
95 $conf = $conf + $wgJobTypeConf[
'default'];
111 public function push( $jobs ) {
112 $jobs = is_array( $jobs ) ? $jobs :
array( $jobs );
113 if ( !count( $jobs ) ) {
117 $jobsByType =
array();
118 foreach ( $jobs
as $job ) {
120 $jobsByType[
$job->getType()][] =
$job;
122 throw new MWException(
"Attempted to push a non-Job object into a queue." );
127 foreach ( $jobsByType
as $type => $jobs ) {
128 if ( $this->
get(
$type )->
push( $jobs ) ) {
135 if ( $this->
cache->has(
'queues-ready',
'list' ) ) {
136 $list = $this->
cache->get(
'queues-ready',
'list' );
137 if ( count( array_diff( array_keys( $jobsByType ), $list ) ) ) {
138 $this->
cache->clear(
'queues-ready' );
156 public function pop( $qtype = self::TYPE_DEFAULT,
$flags = 0,
array $blacklist =
array() ) {
159 if ( is_string( $qtype ) ) {
160 if ( !in_array( $qtype, $blacklist ) ) {
161 $job = $this->
get( $qtype )->
pop();
167 if (
$flags & self::USE_CACHE ) {
168 if ( !$this->
cache->has(
'queues-ready',
'list', self::PROC_CACHE_TTL ) ) {
171 $types = $this->
cache->get(
'queues-ready',
'list' );
176 if ( $qtype == self::TYPE_DEFAULT ) {
180 $types = array_diff( $types, $blacklist );
189 $this->
cache->clear(
'queues-ready' );
231 foreach ( $wgJobTypeConf
as $type => $conf ) {
252 global $wgJobTypesExcludedFromDefaultQueue;
254 return array_diff( $this->
getQueueTypes(), $wgJobTypesExcludedFromDefaultQueue );
272 if ( $type == self::TYPE_DEFAULT ) {
275 $value = count( $queues ) ?
'true' :
'false';
279 return (
$value ===
'true' );
290 $nonEmpty = $info[
'queue']->getSiblingQueuesWithJobs( $this->
getQueueTypes() );
291 if ( is_array( $nonEmpty ) ) {
292 $types = array_merge( $types, $nonEmpty );
294 foreach ( $info[
'types']
as $type ) {
295 if ( !$this->
get( $type )->isEmpty() ) {
313 $sizes = $info[
'queue']->getSiblingQueueSizes( $this->
getQueueTypes() );
314 if ( is_array( $sizes ) ) {
315 $sizeMap = $sizeMap + $sizes;
317 foreach ( $info[
'types']
as $type ) {
318 $sizeMap[
$type] = $this->
get(
$type )->getSize();
332 if ( $this->coalescedQueues ===
null ) {
333 $this->coalescedQueues =
array();
334 foreach ( $wgJobTypeConf
as $type => $conf ) {
336 array(
'wiki' => $this->
wiki,
'type' =>
'null' ) + $conf );
337 $loc = $queue->getCoalesceLocationInternal();
338 if ( !isset( $this->coalescedQueues[$loc] ) ) {
339 $this->coalescedQueues[$loc][
'queue'] = $queue;
340 $this->coalescedQueues[$loc][
'types'] =
array();
342 if (
$type ===
'default' ) {
343 $this->coalescedQueues[$loc][
'types'] = array_merge(
344 $this->coalescedQueues[$loc][
'types'],
345 array_diff( $this->
getQueueTypes(), array_keys( $wgJobTypeConf ) )
348 $this->coalescedQueues[$loc][
'types'][] =
$type;
370 $lastRuns =
$wgMemc->get( $key );
375 $queue = $this->
get(
$type );
376 foreach ( $queue->getPeriodicTasks()
as $task => $definition ) {
377 if ( $definition[
'period'] <= 0 ) {
379 } elseif ( !isset( $lastRuns[
$type][$task] )
380 || $lastRuns[
$type][$task] < ( time() - $definition[
'period'] )
383 if ( call_user_func( $definition[
'callback'] ) !==
null ) {
384 $tasksRun[
$type][$task] = time();
393 if ( isset( $tasksRun[
$type] ) && !$queue->isEmpty() ) {
398 $wgMemc->merge( $key,
function (
$cache, $key, $lastRuns ) use ( $tasksRun ) {
399 if ( is_array( $lastRuns ) ) {
400 foreach ( $tasksRun
as $type => $tasks ) {
402 if ( !isset( $lastRuns[
$type][$task] )
410 $lastRuns = $tasksRun;
432 if ( is_array(
$value ) ) {
436 $wgMemc->set( $key,
array(
'v' =>
$value ), 86400 + mt_rand( 0, 86400 ) );
waitForBackups()
Wait for any slaves or backup queue servers to catch up.
executeReadyPeriodicTasks()
Execute any due periodic queue maintenance tasks for all queues.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
array $coalescedQueues
Map of (bucket => (queue => JobQueue, types => list of types) *.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
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
wfProfileIn( $functionname)
Begin profiling of a function.
queuesHaveJobs( $type=self::TYPE_ANY)
Check if there are any queues with jobs (this is cached)
wfSplitWikiID( $wiki)
Split a wiki ID into DB name and table prefix.
static destroySingletons()
Destroy the singleton instances.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
you have access to all of the normal MediaWiki so you can get a DB use the cache
Class to both describe a background job and handle jobs.
wfMemcKey()
Get a cache key.
push( $jobs)
Insert jobs into the respective queues of with the belong.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
getCachedConfigVar( $name)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfForeignMemcKey( $db, $prefix)
Get a cache key for a foreign DB.
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
processing should stop and the error should be shown to the user * false
getDefaultQueueTypes()
Get the list of default queue types.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Allows to change the fields on the form that will be generated $name
static factory(array $params)
Get a job queue object of the specified type.
pop( $qtype=self::TYPE_DEFAULT, $flags=0, array $blacklist=array())
Pop a job off one of the job queues.
deduplicateRootJob(Job $job)
Register the "root job" of a given job into the queue for de-duplication.
ack(Job $job)
Acknowledge that a job was completed.
if(count( $args)< 1) $job
getQueueTypes()
Get the list of queue types.
static singleton( $wiki=false)
getQueuesWithJobs()
Get the list of job types that have non-empty queues.
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
static logException(Exception $e)
Log an exception to the exception log (if enabled).
Handles per process caching of items.
getQueueSizes()
Get the size of the queus for a list of job types.
Job queue task description interface.
Class to handle enqueueing of background jobs.