Fix names of parsercache_selective_* stats
[mediawiki.git] / maintenance / addChangeTag.php
blob8cd3382ed278d2813881239486166fb3918d6681
1 <?php
3 /**
4 * Adds a change tag to the wiki.
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.
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.
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
21 * @file
22 * @ingroup Maintenance
25 use MediaWiki\Permissions\UltimateAuthority;
26 use MediaWiki\User\User;
28 // @codeCoverageIgnoreStart
29 require_once __DIR__ . '/Maintenance.php';
30 // @codeCoverageIgnoreEnd
32 /**
33 * Adds a change tag to the wiki
35 * @ingroup Maintenance
36 * @since 1.32
38 class AddChangeTag extends Maintenance {
40 public function __construct() {
41 parent::__construct();
42 $this->addDescription( 'Adds a change tag to the wiki.' );
44 $this->addOption( 'tag', 'Tag to add', true, true );
45 $this->addOption( 'reason', 'Reason for adding the tag', true, true );
48 public function execute() {
49 $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] );
51 $tag = $this->getOption( 'tag' );
53 $status = ChangeTags::createTagWithChecks(
54 $tag,
55 $this->getOption( 'reason' ),
56 new UltimateAuthority( $user )
59 if ( !$status->isGood() ) {
60 $this->fatalError( $status );
63 $this->output( "$tag was created.\n" );
67 // @codeCoverageIgnoreStart
68 $maintClass = AddChangeTag::class;
69 require_once RUN_MAINTENANCE_IF_MAIN;
70 // @codeCoverageIgnoreEnd