MediaWiki REL1_34
addChangeTag.php
Go to the documentation of this file.
1<?php
2
25require_once __DIR__ . '/Maintenance.php';
26
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
49 $tag,
50 $this->getOption( 'reason' ),
51 $user
52 );
53
54 if ( !$status->isGood() ) {
55 $this->fatalError( $status->getMessage( false, false, 'en' )->text() );
56 }
57
58 $this->output( "$tag was created.\n" );
59 }
60}
61
62$maintClass = AddChangeTag::class;
63require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
$maintClass
Adds a change tag to the wiki.
__construct()
Default constructor.
execute()
Do the actual work.
static createTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false, array $logEntryTags=[])
Creates a tag by adding it to change_tag_def table.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
Definition User.php:740