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