| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
use MediaWiki\Maintenance\Maintenance; |
| 26 |
use MediaWiki\Permissions\UltimateAuthority; |
| 27 |
use MediaWiki\User\User; |
| 28 |
|
| 29 |
|
| 30 |
require_once __DIR__ . '/Maintenance.php'; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class AddChangeTag extends Maintenance { |
| 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 |
|
| 54 |
$status = ChangeTags::createTagWithChecks( |
| 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 |
|
| 69 |
$maintClass = AddChangeTag::class; |
| 70 |
require_once RUN_MAINTENANCE_IF_MAIN; |
| 71 |
|