MediaWiki master
addChangeTag.php
Go to the documentation of this file.
1<?php
2
29
30// @codeCoverageIgnoreStart
31require_once __DIR__ . '/Maintenance.php';
32// @codeCoverageIgnoreEnd
33
41
42 public function __construct() {
43 parent::__construct();
44 $this->addDescription( 'Adds a change tag to the wiki.' );
45
46 $this->addOption( 'tag', 'Tag to add', true, true );
47 $this->addOption( 'reason', 'Reason for adding the tag', true, true );
48 }
49
50 public function execute() {
51 $user = User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] );
52
53 $tag = $this->getOption( 'tag' );
54
55 $status = ChangeTags::createTagWithChecks(
56 $tag,
57 $this->getOption( 'reason' ),
58 new UltimateAuthority( $user )
59 );
60
61 if ( !$status->isGood() ) {
62 $this->fatalError( $status );
63 }
64
65 $this->output( "$tag was created.\n" );
66 }
67}
68
69// @codeCoverageIgnoreStart
70$maintClass = AddChangeTag::class;
71require_once RUN_MAINTENANCE_IF_MAIN;
72// @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:123