57 abstract public function run();
71 if ( isset( $wgJobClasses[
$command] ) ) {
94 $this->removeDuplicates =
false;
96 if ( !isset( $this->params[
'requestId'] ) ) {
144 return isset( $this->params[
'jobReleaseTimestamp'] )
154 return isset( $this->metadata[
'timestamp'] )
166 return isset( $this->params[
'requestId'] )
167 ? $this->params[
'requestId']
223 'namespace' => $this->
getTitle()->getNamespace(),
224 'title' => $this->
getTitle()->getDBkey(),
227 if ( is_array( $info[
'params'] ) ) {
229 unset( $info[
'params'][
'rootJobSignature'] );
230 unset( $info[
'params'][
'rootJobTimestamp'] );
232 unset( $info[
'params'][
'jobReleaseTimestamp'] );
234 unset( $info[
'params'][
'requestId'] );
236 ksort( $info[
'params'] );
263 'rootJobIsSelf' =>
true,
264 'rootJobSignature' => sha1( $key ),
276 'rootJobSignature' => isset( $this->params[
'rootJobSignature'] )
277 ? $this->params[
'rootJobSignature']
279 'rootJobTimestamp' => isset( $this->params[
'rootJobTimestamp'] )
280 ? $this->params[
'rootJobTimestamp']
291 return isset( $this->params[
'rootJobSignature'] )
292 && isset( $this->params[
'rootJobTimestamp'] );
300 return $this->
hasRootJobParams() && !empty( $this->params[
'rootJobIsSelf'] );
310 $this->teardownCallbacks[] = $callback;
319 foreach ( $this->teardownCallbacks
as $callback ) {
320 call_user_func( $callback,
$status );
339 if ( $this->params ) {
340 foreach ( $this->params
as $key =>
$value ) {
341 if ( $paramString !=
'' ) {
344 if ( is_array(
$value ) ) {
348 if ( $json ===
false || mb_strlen( $json ) > 512 ) {
349 $filteredValue[$k] = gettype( $v ) .
'(...)';
351 $filteredValue[$k] = $v;
354 if ( count( $filteredValue ) <= 10 ) {
359 } elseif ( is_object(
$value ) && !method_exists(
$value,
'__toString' ) ) {
364 if ( mb_strlen(
$value ) > 1024 ) {
365 $flatValue =
"string(" . mb_strlen(
$value ) .
")";
368 $paramString .=
"$key={$flatValue}";
373 foreach ( $this->metadata
as $key =>
$value ) {
374 if ( is_scalar(
$value ) && mb_strlen(
$value ) < 1024 ) {
375 $metaString .= ( $metaString ?
",$key=$value" :
"$key=$value" );
380 if ( is_object( $this->
title ) ) {
381 $s .=
" {$this->title->getPrefixedDBkey()}";
383 if ( $paramString !=
'' ) {
384 $s .=
" $paramString";
386 if ( $metaString !=
'' ) {
387 $s .=
" ($metaString)";
callable[] $teardownCallbacks
static getRequestId()
Get the unique request ID.
addTeardownCallback($callback)
static batchInsert($jobs)
Batch-insert a group of jobs into the queue.
string $error
Text for error that occurred last.
Class to both describe a background job and handle jobs.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
static newRootJobParams($key)
Get "root job" parameters for a task.
when a variable name is used in a it is silently declared as a new local masking the global
insert()
Insert a single job into the queue.
ignoreDuplicates()
Whether the queue should reject insertion of this job if a duplicate exists.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
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 singleton($wiki=false)
__construct($command, $title, $params=false)
bool $removeDuplicates
Expensive jobs may set this to true.
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
static factory($command, Title $title, $params=[])
Create the appropriate object to handle a specific job.
array $metadata
Additional queue metadata.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
array $params
Array of job parameters.
Job queue task description interface.
wfTimestampOrNull($outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
getDeduplicationInfo()
Subclasses may need to override this to make duplication detection work.
teardown($status)
Do any final cleanup after run(), deferred updates, and all DB commits happen.