Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DuplicateJob
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 newFromJob
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 run
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
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\Jobs;
22
23use MediaWiki\JobQueue\GenericParameterJob;
24use MediaWiki\JobQueue\Job;
25use MediaWiki\JobQueue\RunnableJob;
26
27/**
28 * No-op job that does nothing.
29 *
30 * This is used by JobQueue::pop to temporarily represent duplicates.
31 *
32 * @internal
33 * @ingroup JobQueue
34 */
35final class DuplicateJob extends Job implements GenericParameterJob {
36    /**
37     * Callers should use DuplicateJob::newFromJob() instead
38     *
39     * @param array $params Job parameters
40     */
41    public function __construct( array $params ) {
42        parent::__construct( 'duplicate', $params );
43    }
44
45    /**
46     * Get a duplicate no-op version of a job
47     *
48     * @param RunnableJob $job
49     * @return Job
50     */
51    public static function newFromJob( RunnableJob $job ) {
52        $djob = new self( $job->getParams() );
53        $djob->command = $job->getType();
54        $djob->params = is_array( $djob->params ) ? $djob->params : [];
55        $djob->params = [ 'isDuplicate' => true ] + $djob->params;
56        $djob->metadata = $job->getMetadata();
57
58        return $djob;
59    }
60
61    public function run() {
62        return true;
63    }
64}
65
66/** @deprecated class alias since 1.44 */
67class_alias( DuplicateJob::class, 'DuplicateJob' );