Debian Codegraph @

includes/Storage/RevertedTagUpdateManager.php

raw symbols SCIP
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\Storage;
22
23 use JobQueueGroup;
24 use RevertedTagUpdateJob;
25
26 /**
27 * Class for managing delayed RevertedTagUpdateJob waiting for user approval.
28 *
29 * This is intended to be used by the patrol subsystem and various content
30 * management extensions.
31 *
32 * @since 1.36
33 * @author Ostrzyciel
34 */
35 class RevertedTagUpdateManager {
36
37 /** @var JobQueueGroup */
38 private $jobQueueGroup;
39
40 /** @var EditResultCache */
41 private $editResultCache;
42
43 /**
44 * @param EditResultCache $editResultCache
45 * @param JobQueueGroup $jobQueueGroup
46 */
47 public function __construct(
48 EditResultCache $editResultCache,
49 JobQueueGroup $jobQueueGroup
50 ) {
51 $this->jobQueueGroup = $jobQueueGroup;
52 $this->editResultCache = $editResultCache;
53 }
54
55 /**
56 * Enqueue a RevertedTagUpdateJob for the given revision, if needed. Call this when the
57 * user "approves" the edit.
58 *
59 * This method is also called whenever the edit is patrolled or autopatrolled.
60 *
61 * @param int $revertRevisionId
62 *
63 * @return bool Whether the update was enqueued successfully
64 */
65 public function approveRevertedTagForRevision( int $revertRevisionId ): bool {
66 $editResult = $this->editResultCache->get( $revertRevisionId );
67 if ( $editResult === null ) {
68 return false;
69 }
70
71 $spec = RevertedTagUpdateJob::newSpec( $revertRevisionId, $editResult );
72 $this->jobQueueGroup->lazyPush( $spec );
73 return true;
74 }
75 }