From: Reedy Date: Tue, 21 Aug 2018 17:36:45 +0000 (+0100) Subject: Add a maintenance script to add a Change Tag X-Git-Tag: 1.34.0-rc.0~4346^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=d20f246683178c0b40226b6c0164459fff375c05;p=lhc%2Fweb%2Fwiklou.git Add a maintenance script to add a Change Tag Change-Id: I51406b0e9140e5a462d9dd256b1d949fa09b67a0 --- diff --git a/autoload.php b/autoload.php index 8679827dcb..d8f9578a24 100644 --- a/autoload.php +++ b/autoload.php @@ -12,6 +12,7 @@ $wgAutoloadLocalClasses = [ 'ActiveUsersPager' => __DIR__ . '/includes/specials/pagers/ActiveUsersPager.php', 'ActivityUpdateJob' => __DIR__ . '/includes/jobqueue/jobs/ActivityUpdateJob.php', 'ActorMigration' => __DIR__ . '/includes/ActorMigration.php', + 'AddChangeTag' => __DIR__ . '/maintenance/addChangeTag.php', 'AddRFCandPMIDInterwiki' => __DIR__ . '/maintenance/addRFCandPMIDInterwiki.php', 'AddSite' => __DIR__ . '/maintenance/addSite.php', 'AjaxDispatcher' => __DIR__ . '/includes/AjaxDispatcher.php', diff --git a/maintenance/addChangeTag.php b/maintenance/addChangeTag.php new file mode 100644 index 0000000000..b63a2e2b82 --- /dev/null +++ b/maintenance/addChangeTag.php @@ -0,0 +1,63 @@ +addDescription( 'Adds a change tag to the wiki.' ); + + $this->addOption( 'tag', 'Tag to add', true, true ); + $this->addOption( 'reason', 'Reason for adding the tag', true, true ); + } + + public function execute() { + $user = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] ); + + $tag = $this->getOption( 'tag' ); + + $status = ChangeTags::createTagWithChecks( + $tag, + $this->getOption( 'reason' ), + $user + ); + + if ( !$status->isGood() ) { + $this->fatalError( $status->getWikiText( null, null, 'en' ) ); + } + + $this->output( "$tag was created.\n" ); + } +} + +$maintClass = AddChangeTag::class; +require_once RUN_MAINTENANCE_IF_MAIN;