Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CentralAuthSuppressUserJob | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
run | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | /** |
3 | * @section LICENSE |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * http://www.gnu.org/copyleft/gpl.html |
18 | * |
19 | * @file |
20 | */ |
21 | |
22 | namespace MediaWiki\Extension\CentralAuth\User; |
23 | |
24 | use Job; |
25 | use MediaWiki\Logger\LoggerFactory; |
26 | |
27 | /** |
28 | * A job to do crosswiki suppression in batches, rather than |
29 | * in one request. Size of batch is changed by changing |
30 | * $wgCentralAuthWikisPerSuppressJob. |
31 | */ |
32 | class CentralAuthSuppressUserJob extends Job { |
33 | |
34 | /** |
35 | * @param array $params Job parameters |
36 | */ |
37 | public function __construct( $params ) { |
38 | parent::__construct( 'crosswikiSuppressUser', $params ); |
39 | } |
40 | |
41 | /** |
42 | * Execute the job |
43 | * |
44 | * @return bool |
45 | */ |
46 | public function run() { |
47 | $username = $this->params['username']; |
48 | $by = $this->params['by']; |
49 | $wikis = $this->params['wikis']; |
50 | $suppress = $this->params['suppress']; |
51 | $reason = $this->params['reason']; |
52 | $user = CentralAuthUser::getPrimaryInstanceByName( $username ); |
53 | $logger = LoggerFactory::getInstance( 'CentralAuth' ); |
54 | if ( !$user->exists() ) { |
55 | $logger->debug( "Requested to suppress non-existent user {$username} by {$by}" ); |
56 | } |
57 | |
58 | foreach ( $wikis as $wiki ) { |
59 | $user->doLocalSuppression( $suppress, $wiki, $by, $reason ); |
60 | $logger->debug( |
61 | $suppress |
62 | ? "Suppressed {$username} at {$wiki} by {$by} via job queue" |
63 | : "Unsuppressed {$username} at {$wiki} by {$by} via job queue" |
64 | ); |
65 | } |
66 | return true; |
67 | } |
68 | } |