MediaWiki master
addChangeTag.php
Go to the documentation of this file.
1<?php
2
28
29// @codeCoverageIgnoreStart
30require_once __DIR__ . '/Maintenance.php';
31// @codeCoverageIgnoreEnd
32
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
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;
70require_once RUN_MAINTENANCE_IF_MAIN;
71// @codeCoverageIgnoreEnd
$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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
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.
addDescription( $text)
Set the description text.
Represents an authority that has all permissions.
User class for the MediaWiki software.
Definition User.php:119