MediaWiki master
addChangeTag.php
Go to the documentation of this file.
1<?php
2
15
16// @codeCoverageIgnoreStart
17require_once __DIR__ . '/Maintenance.php';
18// @codeCoverageIgnoreEnd
19
27
28 public function __construct() {
29 parent::__construct();
30 $this->addDescription( 'Adds a change tag to the wiki.' );
31
32 $this->addOption( 'tag', 'Tag to add', true, true );
33 $this->addOption( 'reason', 'Reason for adding the tag', true, true );
34 }
35
36 public function execute() {
37 $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] );
38
39 $tag = $this->getOption( 'tag' );
40
41 $status = ChangeTags::createTagWithChecks(
42 $tag,
43 $this->getOption( 'reason' ),
44 new UltimateAuthority( $user )
45 );
46
47 if ( !$status->isGood() ) {
48 $this->fatalError( $status );
49 }
50
51 $this->output( "$tag was created.\n" );
52 }
53}
54
55// @codeCoverageIgnoreStart
56$maintClass = AddChangeTag::class;
57require_once RUN_MAINTENANCE_IF_MAIN;
58// @codeCoverageIgnoreEnd
$maintClass
Adds a change tag to the wiki.
__construct()
Default constructor.
execute()
Do the actual work.
Recent changes tagging.
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:130