Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / maintenance / addChangeTag.php
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 require_once __DIR__ . '/Maintenance.php';
26
27 /**
28 * Adds a change tag to the wiki
29 *
30 * @ingroup Maintenance
31 * @since 1.32
32 */
33 class AddChangeTag extends Maintenance {
34
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( 'Adds a change tag to the wiki.' );
38
39 $this->addOption( 'tag', 'Tag to add', true, true );
40 $this->addOption( 'reason', 'Reason for adding the tag', true, true );
41 }
42
43 public function execute() {
44 $user = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] );
45
46 $tag = $this->getOption( 'tag' );
47
48 $status = ChangeTags::createTagWithChecks(
49 $tag,
50 $this->getOption( 'reason' ),
51 $user
52 );
53
54 if ( !$status->isGood() ) {
55 $this->fatalError( $status->getWikiText( null, null, 'en' ) );
56 }
57
58 $this->output( "$tag was created.\n" );
59 }
60 }
61
62 $maintClass = AddChangeTag::class;
63 require_once RUN_MAINTENANCE_IF_MAIN;