MediaWiki  1.29.1
JobQueueAggregator.php
Go to the documentation of this file.
1 <?php
30 abstract class JobQueueAggregator {
32  protected static $instance = null;
33 
37  public function __construct( array $params ) {
38  }
39 
44  final public static function singleton() {
45  global $wgJobQueueAggregator;
46 
47  if ( !isset( self::$instance ) ) {
48  $class = $wgJobQueueAggregator['class'];
49  $obj = new $class( $wgJobQueueAggregator );
50  if ( !( $obj instanceof JobQueueAggregator ) ) {
51  throw new MWException( "Class '$class' is not a JobQueueAggregator class." );
52  }
53  self::$instance = $obj;
54  }
55 
56  return self::$instance;
57  }
58 
64  final public static function destroySingleton() {
65  self::$instance = null;
66  }
67 
75  final public function notifyQueueEmpty( $wiki, $type ) {
76  $ok = $this->doNotifyQueueEmpty( $wiki, $type );
77 
78  return $ok;
79  }
80 
84  abstract protected function doNotifyQueueEmpty( $wiki, $type );
85 
93  final public function notifyQueueNonEmpty( $wiki, $type ) {
94  $ok = $this->doNotifyQueueNonEmpty( $wiki, $type );
95 
96  return $ok;
97  }
98 
102  abstract protected function doNotifyQueueNonEmpty( $wiki, $type );
103 
109  final public function getAllReadyWikiQueues() {
110  $res = $this->doGetAllReadyWikiQueues();
111 
112  return $res;
113  }
114 
118  abstract protected function doGetAllReadyWikiQueues();
119 
125  final public function purge() {
126  $res = $this->doPurge();
127 
128  return $res;
129  }
130 
134  abstract protected function doPurge();
135 
142  protected function findPendingWikiQueues() {
144 
145  $pendingDBs = []; // (job type => (db list))
146  foreach ( $wgLocalDatabases as $db ) {
147  foreach ( JobQueueGroup::singleton( $db )->getQueuesWithJobs() as $type ) {
148  $pendingDBs[$type][] = $db;
149  }
150  }
151 
152  return $pendingDBs;
153  }
154 }
155 
157  protected function doNotifyQueueEmpty( $wiki, $type ) {
158  return true;
159  }
160 
161  protected function doNotifyQueueNonEmpty( $wiki, $type ) {
162  return true;
163  }
164 
165  protected function doGetAllReadyWikiQueues() {
166  return [];
167  }
168 
169  protected function doPurge() {
170  return true;
171  }
172 }
JobQueueAggregator\doNotifyQueueNonEmpty
doNotifyQueueNonEmpty( $wiki, $type)
JobQueueAggregatorNull\doNotifyQueueEmpty
doNotifyQueueEmpty( $wiki, $type)
Definition: JobQueueAggregator.php:157
JobQueueAggregator\purge
purge()
Purge all of the aggregator information.
Definition: JobQueueAggregator.php:125
JobQueueAggregator\__construct
__construct(array $params)
Definition: JobQueueAggregator.php:37
JobQueueAggregator\notifyQueueNonEmpty
notifyQueueNonEmpty( $wiki, $type)
Mark a queue as being non-empty.
Definition: JobQueueAggregator.php:93
JobQueueAggregatorNull\doPurge
doPurge()
Definition: JobQueueAggregator.php:169
$params
$params
Definition: styleTest.css.php:40
JobQueueAggregatorNull\doNotifyQueueNonEmpty
doNotifyQueueNonEmpty( $wiki, $type)
Definition: JobQueueAggregator.php:161
$res
$res
Definition: database.txt:21
$type
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 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
Definition: hooks.txt:2536
JobQueueAggregatorNull
Definition: JobQueueAggregator.php:156
php
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
Definition: injection.txt:35
JobQueueAggregator\destroySingleton
static destroySingleton()
Destroy the singleton instance.
Definition: JobQueueAggregator.php:64
JobQueueAggregator
Class to handle tracking information about all queues.
Definition: JobQueueAggregator.php:30
JobQueueAggregator\$instance
static JobQueueAggregator $instance
Definition: JobQueueAggregator.php:32
MWException
MediaWiki exception.
Definition: MWException.php:26
JobQueueAggregatorNull\doGetAllReadyWikiQueues
doGetAllReadyWikiQueues()
Definition: JobQueueAggregator.php:165
JobQueueAggregator\getAllReadyWikiQueues
getAllReadyWikiQueues()
Get the list of all of the queues with jobs.
Definition: JobQueueAggregator.php:109
JobQueueAggregator\doGetAllReadyWikiQueues
doGetAllReadyWikiQueues()
JobQueueAggregator\notifyQueueEmpty
notifyQueueEmpty( $wiki, $type)
Mark a queue as being empty.
Definition: JobQueueAggregator.php:75
JobQueueAggregator\doNotifyQueueEmpty
doNotifyQueueEmpty( $wiki, $type)
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$wgLocalDatabases
$wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
Definition: DefaultSettings.php:2047
JobQueueAggregator\doPurge
doPurge()
JobQueueAggregator\findPendingWikiQueues
findPendingWikiQueues()
Get all databases that have a pending job.
Definition: JobQueueAggregator.php:142
JobQueueGroup\singleton
static singleton( $wiki=false)
Definition: JobQueueGroup.php:71
as
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
Definition: distributors.txt:9
JobQueueAggregator\singleton
static singleton()
Definition: JobQueueAggregator.php:44
array
the array() calling protocol came about after MediaWiki 1.4rc1.