Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
AddChangeTag | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 |
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\Maintenance\Maintenance; |
26 | use MediaWiki\Permissions\UltimateAuthority; |
27 | use MediaWiki\User\User; |
28 | |
29 | // @codeCoverageIgnoreStart |
30 | require_once __DIR__ . '/Maintenance.php'; |
31 | // @codeCoverageIgnoreEnd |
32 | |
33 | /** |
34 | * Adds a change tag to the wiki |
35 | * |
36 | * @ingroup Maintenance |
37 | * @since 1.32 |
38 | */ |
39 | class AddChangeTag extends Maintenance { |
40 | |
41 | public function __construct() { |
42 | parent::__construct(); |
43 | $this->addDescription( 'Adds a change tag to the wiki.' ); |
44 | |
45 | $this->addOption( 'tag', 'Tag to add', true, true ); |
46 | $this->addOption( 'reason', 'Reason for adding the tag', true, true ); |
47 | } |
48 | |
49 | public function execute() { |
50 | $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] ); |
51 | |
52 | $tag = $this->getOption( 'tag' ); |
53 | |
54 | $status = ChangeTags::createTagWithChecks( |
55 | $tag, |
56 | $this->getOption( 'reason' ), |
57 | new UltimateAuthority( $user ) |
58 | ); |
59 | |
60 | if ( !$status->isGood() ) { |
61 | $this->fatalError( $status ); |
62 | } |
63 | |
64 | $this->output( "$tag was created.\n" ); |
65 | } |
66 | } |
67 | |
68 | // @codeCoverageIgnoreStart |
69 | $maintClass = AddChangeTag::class; |
70 | require_once RUN_MAINTENANCE_IF_MAIN; |
71 | // @codeCoverageIgnoreEnd |