MediaWiki master
addChangeTag.php
Go to the documentation of this file.
1<?php
2
27
28require_once __DIR__ . '/Maintenance.php';
29
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
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;
66require_once RUN_MAINTENANCE_IF_MAIN;
$maintClass
Adds a change tag to the wiki.
__construct()
Default constructor.
execute()
Do the actual work.
static createTagWithChecks(string $tag, string $reason, Authority $performer, bool $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.
Represents an authority that has all permissions.
internal since 1.36
Definition User.php:93