Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21namespace MediaWiki\JobQueue;
22
23/**
24 * Interface for serializable objects that describe a job queue task
25 *
26 * A job specification can be inserted into a queue via JobQueue::push().
27 * The specification parameters should be JSON serializable (e.g. no PHP classes).
28 * Whatever queue the job specification is pushed into is assumed to have job runners
29 * that will eventually pop the job specification from the queue, construct a RunnableJob
30 * instance from the specification, and then execute that instance via RunnableJob::run().
31 *
32 * Job classes must have a constructor that takes a Title and a parameter array, except
33 * when they also implement GenericParameterJob in which case they must only take an array.
34 * When reconstructing the job from the job queue, the value returned from getParams() will
35 * be passed in as the constructor's array parameter; the title will be constructed from
36 * the parameter array's `namespace` and `title` fields (when these are omitted, some
37 * fallback title will be used).
38 *
39 * @ingroup JobQueue
40 * @since 1.23
41 */
42interface IJobSpecification {
43    /**
44     * @return string Job type that defines what sort of changes this job makes
45     */
46    public function getType();
47
48    /**
49     * @return array Parameters that specify sources, targets, and options for execution
50     */
51    public function getParams();
52
53    /**
54     * @return int|null UNIX timestamp to delay running this job until, otherwise null
55     */
56    public function getReleaseTimestamp();
57
58    /**
59     * @return bool Whether only one of each identical set of jobs should be run
60     */
61    public function ignoreDuplicates();
62
63    /**
64     * Subclasses may need to override this to make duplication detection work.
65     * The resulting map conveys everything that makes the job unique. This is
66     * only checked if ignoreDuplicates() returns true, meaning that duplicate
67     * jobs are supposed to be ignored.
68     *
69     * @return array Map of key/values
70     */
71    public function getDeduplicationInfo();
72
73    /**
74     * @see JobQueue::deduplicateRootJob()
75     * @return array
76     * @since 1.26
77     */
78    public function getRootJobParams();
79
80    /**
81     * @see JobQueue::deduplicateRootJob()
82     * @return bool
83     * @since 1.22
84     */
85    public function hasRootJobParams();
86
87    /**
88     * @see JobQueue::deduplicateRootJob()
89     * @return bool Whether this is job is a root job
90     */
91    public function isRootJob();
92}
93
94/** @deprecated class alias since 1.44 */
95class_alias( IJobSpecification::class, 'IJobSpecification' );