Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
96.30% |
26 / 27 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
RevertedTagUpdateJob | |
100.00% |
26 / 26 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
newSpec | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
run | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
1 |
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 | |
21 | namespace MediaWiki\JobQueue\Jobs; |
22 | |
23 | use MediaWiki\Config\ServiceOptions; |
24 | use MediaWiki\JobQueue\GenericParameterJob; |
25 | use MediaWiki\JobQueue\Job; |
26 | use MediaWiki\JobQueue\JobSpecification; |
27 | use MediaWiki\Logger\LoggerFactory; |
28 | use MediaWiki\MediaWikiServices; |
29 | use MediaWiki\Storage\EditResult; |
30 | use MediaWiki\Storage\RevertedTagUpdate; |
31 | |
32 | /** |
33 | * Job for deferring the execution of RevertedTagUpdate. |
34 | * |
35 | * @internal For use by \MediaWiki\Storage\RevertedTagUpdate |
36 | * @since 1.36 |
37 | * @ingroup JobQueue |
38 | * @author Ostrzyciel |
39 | */ |
40 | class RevertedTagUpdateJob extends Job implements GenericParameterJob { |
41 | |
42 | /** |
43 | * Returns a JobSpecification for this job. |
44 | * |
45 | * @param int $revertRevisionId |
46 | * @param EditResult $editResult |
47 | * |
48 | * @return JobSpecification |
49 | */ |
50 | public static function newSpec( |
51 | int $revertRevisionId, |
52 | EditResult $editResult |
53 | ): JobSpecification { |
54 | return new JobSpecification( |
55 | 'revertedTagUpdate', |
56 | [ |
57 | 'revertId' => $revertRevisionId, |
58 | 'editResult' => $editResult->jsonSerialize() |
59 | ] |
60 | ); |
61 | } |
62 | |
63 | /** |
64 | * @param array $params |
65 | * @phan-param array{revertId:int,editResult:array} $params |
66 | */ |
67 | public function __construct( array $params ) { |
68 | parent::__construct( 'revertedTagUpdate', $params ); |
69 | } |
70 | |
71 | /** |
72 | * Unpacks the job arguments and runs the update. |
73 | * |
74 | * @return bool |
75 | */ |
76 | public function run() { |
77 | $services = MediaWikiServices::getInstance(); |
78 | $editResult = EditResult::newFromArray( |
79 | $this->params['editResult'] |
80 | ); |
81 | |
82 | $update = new RevertedTagUpdate( |
83 | $services->getRevisionStore(), |
84 | LoggerFactory::getInstance( 'RevertedTagUpdate' ), |
85 | $services->getChangeTagsStore(), |
86 | $services->getConnectionProvider(), |
87 | new ServiceOptions( |
88 | RevertedTagUpdate::CONSTRUCTOR_OPTIONS, |
89 | $services->getMainConfig() |
90 | ), |
91 | $this->params['revertId'], |
92 | $editResult |
93 | ); |
94 | |
95 | $update->doUpdate(); |
96 | return true; |
97 | } |
98 | } |
99 | |
100 | /** @deprecated class alias since 1.44 */ |
101 | class_alias( RevertedTagUpdateJob::class, 'RevertedTagUpdateJob' ); |