Add a maintenance script to add a Change Tag
authorReedy <reedy@wikimedia.org>
Tue, 21 Aug 2018 17:36:45 +0000 (18:36 +0100)
committerReedy <reedy@wikimedia.org>
Tue, 21 Aug 2018 18:32:02 +0000 (18:32 +0000)
Change-Id: I51406b0e9140e5a462d9dd256b1d949fa09b67a0

autoload.php
maintenance/addChangeTag.php [new file with mode: 0644]

index 8679827..d8f9578 100644 (file)
@@ -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 (file)
index 0000000..b63a2e2
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Adds a change tag to the wiki.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Adds a change tag to the wiki
+ *
+ * @ingroup Maintenance
+ * @since 1.32
+ */
+class AddChangeTag extends Maintenance {
+
+       public function __construct() {
+               parent::__construct();
+               $this->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;