MediaWiki REL1_28
Go to the documentation of this file.
28require_once __DIR__ . '/Maintenance.php';
36class ShowJobs extends Maintenance {
37 protected static $stateMethods = [
38 'unclaimed' => 'getAllQueuedJobs',
39 'delayed' => 'getAllDelayedJobs',
40 'claimed' => 'getAllAcquiredJobs',
41 'abandoned' => 'getAllAbandonedJobs',
42 ];
44 public function __construct() {
45 parent::__construct();
46 $this->addDescription( 'Show number of jobs waiting in master database' );
47 $this->addOption( 'group', 'Show number of jobs per job type' );
48 $this->addOption( 'list', 'Show a list of all jobs instead of counts' );
49 $this->addOption( 'type', 'Only show/count jobs of a given type', false, true );
50 $this->addOption( 'status', 'Filter list by state (unclaimed,delayed,claimed,abandoned)' );
51 $this->addOption( 'limit', 'Limit of jobs listed' );
52 }
54 public function execute() {
55 $typeFilter = $this->getOption( 'type', '' );
56 $stateFilter = $this->getOption( 'status', '' );
57 $stateLimit = (float)$this->getOption( 'limit', INF );
59 $group = JobQueueGroup::singleton();
61 $filteredTypes = $typeFilter
62 ? [ $typeFilter ]
63 : $group->getQueueTypes();
64 $filteredStates = $stateFilter
65 ? array_intersect_key( self::$stateMethods, [ $stateFilter => 1 ] )
68 if ( $this->hasOption( 'list' ) ) {
69 $count = 0;
70 foreach ( $filteredTypes as $type ) {
71 $queue = $group->get( $type );
72 foreach ( $filteredStates as $state => $method ) {
73 foreach ( $queue->$method() as $job ) {
75 $this->output( $job->toString() . " status=$state\n" );
76 if ( ++$count >= $stateLimit ) {
77 return;
78 }
79 }
80 }
81 }
82 } elseif ( $this->hasOption( 'group' ) ) {
83 foreach ( $filteredTypes as $type ) {
84 $queue = $group->get( $type );
85 $delayed = $queue->getDelayedCount();
86 $pending = $queue->getSize();
87 $claimed = $queue->getAcquiredCount();
88 $abandoned = $queue->getAbandonedCount();
89 $active = max( 0, $claimed - $abandoned );
90 if ( ( $pending + $claimed + $delayed + $abandoned ) > 0 ) {
91 $this->output(
92 "{$type}: $pending queued; " .
93 "$claimed claimed ($active active, $abandoned abandoned); " .
94 "$delayed delayed\n"
95 );
96 }
97 }
98 } else {
99 $count = 0;
100 foreach ( $filteredTypes as $type ) {
101 $count += $group->get( $type )->getSize();
102 }
103 $this->output( "$count\n" );
104 }
105 }
108$maintClass = "ShowJobs";
109require_once RUN_MAINTENANCE_IF_MAIN;
static singleton( $wiki=false)
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
Maintenance script that reports the number of jobs currently waiting in master database.
Definition showJobs.php:36
Do the actual work.
Definition showJobs.php:54
Default constructor.
Definition showJobs.php:44
static $stateMethods
Definition showJobs.php:37
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
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
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
Definition hooks.txt:2568
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:37
if(count( $args)< 1) $job
Definition showJobs.php:108