Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
AddChangeTag | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * Adds a change tag to the wiki. |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; if not, write to the Free Software Foundation, Inc., |
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | * http://www.gnu.org/copyleft/gpl.html |
20 | * |
21 | * @file |
22 | * @ingroup Maintenance |
23 | */ |
24 | |
25 | use MediaWiki\Permissions\UltimateAuthority; |
26 | use MediaWiki\User\User; |
27 | |
28 | require_once __DIR__ . '/Maintenance.php'; |
29 | |
30 | /** |
31 | * Adds a change tag to the wiki |
32 | * |
33 | * @ingroup Maintenance |
34 | * @since 1.32 |
35 | */ |
36 | class AddChangeTag extends Maintenance { |
37 | |
38 | public function __construct() { |
39 | parent::__construct(); |
40 | $this->addDescription( 'Adds a change tag to the wiki.' ); |
41 | |
42 | $this->addOption( 'tag', 'Tag to add', true, true ); |
43 | $this->addOption( 'reason', 'Reason for adding the tag', true, true ); |
44 | } |
45 | |
46 | public function execute() { |
47 | $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] ); |
48 | |
49 | $tag = $this->getOption( 'tag' ); |
50 | |
51 | $status = ChangeTags::createTagWithChecks( |
52 | $tag, |
53 | $this->getOption( 'reason' ), |
54 | new UltimateAuthority( $user ) |
55 | ); |
56 | |
57 | if ( !$status->isGood() ) { |
58 | $this->fatalError( $status->getMessage( false, false, 'en' )->text() ); |
59 | } |
60 | |
61 | $this->output( "$tag was created.\n" ); |
62 | } |
63 | } |
64 | |
65 | $maintClass = AddChangeTag::class; |
66 | require_once RUN_MAINTENANCE_IF_MAIN; |