MediaWiki  1.34.0
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;
$maintClass
$maintClass
Definition: addChangeTag.php:62
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
Maintenance\fatalError
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition: Maintenance.php:504
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
User\newSystemUser
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
Definition: User.php:737
AddChangeTag\execute
execute()
Do the actual work.
Definition: addChangeTag.php:43
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:267
AddChangeTag
Adds a change tag to the wiki.
Definition: addChangeTag.php:33
$status
return $status
Definition: SyntaxHighlight.php:347
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:302
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:453
ChangeTags\createTagWithChecks
static createTagWithChecks( $tag, $reason, User $user, $ignoreWarnings=false, array $logEntryTags=[])
Creates a tag by adding it to change_tag_def table.
Definition: ChangeTags.php:1236
AddChangeTag\__construct
__construct()
Default constructor.
Definition: addChangeTag.php:35