MediaWiki  master
addChangeTag.php
Go to the documentation of this file.
1 <?php
2 
25 require_once __DIR__ . '/Maintenance.php';
26 
33 class AddChangeTag extends Maintenance {
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;
63 require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
getOption( $name, $default=null)
Get an option, or return the default.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:86
$maintClass
addDescription( $text)
Set the description text.
output( $out, $channel=null)
Throw some output to the user.
static createTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false, array $logEntryTags=[])
Creates a tag by adding it to change_tag_def table.
Adds a change tag to the wiki.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
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:758