Georggi199 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263828
Change subject: Maintenance: Added script to remove specified change tag
......................................................................
Maintenance: Added script to remove specified change tag
Change-Id: I4e46b05d7c2d1b321398bce7b0974714ef9022c7
---
M includes/changetags/ChangeTags.php
A maintenance/DeleteChangeTag.php
2 files changed, 71 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/28/263828/1
diff --git a/includes/changetags/ChangeTags.php
b/includes/changetags/ChangeTags.php
index 5aac495..f3d4be7 100644
--- a/includes/changetags/ChangeTags.php
+++ b/includes/changetags/ChangeTags.php
@@ -979,10 +979,11 @@
* safely be exposed to users.
*
* @param string $tag Tag to remove
+ * @param int $limit
* @return Status The returned status will be good unless a hook
changed it
* @since 1.25
*/
- public static function deleteTagEverywhere( $tag ) {
+ public static function deleteTagEverywhere( $tag, $limit = 0 ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->startAtomic( __METHOD__ );
@@ -993,7 +994,8 @@
$result = $dbw->select( 'change_tag',
array( 'ct_rc_id', 'ct_log_id', 'ct_rev_id', 'ct_tag' ),
array( 'ct_tag' => $tag ),
- __METHOD__ );
+ __METHOD__,
+ array( 'LIMIT', $limit ) );
foreach ( $result as $row ) {
// remove the tag from the relevant row of tag_summary
$tagsToAdd = array();
diff --git a/maintenance/DeleteChangeTag.php b/maintenance/DeleteChangeTag.php
new file mode 100644
index 0000000..24dc5f4
--- /dev/null
+++ b/maintenance/DeleteChangeTag.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Deletes a batch of pages.
+ * Usage: php deleteChangeTag.php [--tag <tag>] [--l <limit>] [-i <interval>]
[listfile]
+ * where
+ * <tag> is a change tag to delete from the wiki.
+ * <limit> is a number of tags to delete per one cycle.
+ * <interval> is the number of seconds to sleep for after each delete
+ *
+ * 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';
+
+/**
+ * Maintenance script to delete change tag.
+ *
+ * @ingroup Maintenance
+ */
+class DeleteChangeTag extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = 'Deletes change tag';
+ $this->addOption( 'i', 'Interval to sleep between deletions' );
+ $this->addOption( 'tag', 'Change tag to delete from database.',
true, true );
+ $this->addOption( 'l', 'Number of tags to delete per one cycle'
, false, true );
+ }
+
+ public function execute() {
+
+ # Options processing
+ $interval = $this->getOption( 'i', 0 );
+ $tag = $this->getOption( 'tag', '' );
+ $limit = $this->getOption( 'l', 0 );
+
+ $dbw = $this->getDB( DB_MASTER );
+ echo "$tag\n$limit\n." . $dbw->selectField( 'change_tag',
'ct_tag', array( 'ct_tag' => $tag ) );
+ # Handle each page
+ while ( $dbw->selectField( 'change_tag', 'ct_tag', array(
'ct_tag' => $tag ) ) !== false ) {
+ ChangeTags::deleteTagEverywhere( $tag, $limit );
+ if ( $interval ) {
+ sleep( $interval );
+ }
+ wfWaitForSlaves();
+ }
+ }
+}
+
+$maintClass = 'DeleteChangeTag';
+require_once RUN_MAINTENANCE_IF_MAIN;
--
To view, visit https://gerrit.wikimedia.org/r/263828
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e46b05d7c2d1b321398bce7b0974714ef9022c7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Georggi199 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits