MediaWiki REL1_29
manageJobs.php
Go to the documentation of this file.
1<?php
25require_once __DIR__ . '/Maintenance.php';
26
32class ManageJobs extends Maintenance {
33 public function __construct() {
34 parent::__construct();
35 $this->addDescription( 'Perform administrative tasks on a job queue' );
36 $this->addOption( 'type', 'Job type', true, true );
37 $this->addOption( 'action', 'Queue operation ("delete", "repush-abandoned")', true, true );
38 }
39
40 public function execute() {
41 $type = $this->getOption( 'type' );
42 $action = $this->getOption( 'action' );
43
44 $group = JobQueueGroup::singleton();
45 $queue = $group->get( $type );
46
47 if ( $action === 'delete' ) {
48 $this->delete( $queue );
49 } elseif ( $action === 'repush-abandoned' ) {
50 $this->repushAbandoned( $queue );
51 } else {
52 $this->error( "Invalid action '$action'.", 1 );
53 }
54 }
55
56 private function delete( JobQueue $queue ) {
57 $this->output( "Queue has {$queue->getSize()} job(s); deleting...\n" );
58 $queue->delete();
59 $this->output( "Done; current size is {$queue->getSize()} job(s).\n" );
60 }
61
62 private function repushAbandoned( JobQueue $queue ) {
63 $cache = ObjectCache::getInstance( CACHE_DB );
64 $key = $cache->makeGlobalKey( 'last-job-repush', $queue->getWiki(), $queue->getType() );
65
66 $now = wfTimestampNow();
67 $lastRepushTime = $cache->get( $key );
68 if ( $lastRepushTime === false ) {
69 $lastRepushTime = wfTimestamp( TS_MW, 1 ); // include all jobs
70 }
71
72 $this->output( "Last re-push time: $lastRepushTime; current time: $now\n" );
73
74 $count = 0;
75 $skipped = 0;
76 foreach ( $queue->getAllAbandonedJobs() as $job ) {
78 if ( $job->getQueuedTimestamp() < wfTimestamp( TS_UNIX, $lastRepushTime ) ) {
79 ++$skipped;
80 continue; // already re-pushed in prior round
81 }
82
83 $queue->push( $job );
84 ++$count;
85
86 if ( ( $count % $this->mBatchSize ) == 0 ) {
87 $queue->waitForBackups();
88 }
89 }
90
91 $cache->set( $key, $now ); // next run will ignore these jobs
92
93 $this->output( "Re-pushed $count job(s) [$skipped skipped].\n" );
94 }
95}
96
97$maintClass = "ManageJobs";
98require_once RUN_MAINTENANCE_IF_MAIN;
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static singleton( $wiki=false)
Class to handle enqueueing and running of background jobs.
Definition JobQueue.php:32
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
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 handles managing job queue admin tasks (re-push, delete, ....
repushAbandoned(JobQueue $queue)
execute()
Do the actual work.
__construct()
Default constructor.
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
const CACHE_DB
Definition Defines.php:101
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:2604
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
require_once RUN_MAINTENANCE_IF_MAIN
$maintClass
$cache
Definition mcc.php:33
if(count( $args)< 1) $job