Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/203970
Change subject: Add maintenance script to remove HHVM revision tag
......................................................................
Add maintenance script to remove HHVM revision tag
Bug: T75181
Change-Id: Ib8b96b8460db3832e9297a07922ee1d9d1af5ccb
---
A removeHHVMTag.php
1 file changed, 79 insertions(+), 0 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaMaintenance
refs/changes/70/203970/1
diff --git a/removeHHVMTag.php b/removeHHVMTag.php
new file mode 100644
index 0000000..8688211
--- /dev/null
+++ b/removeHHVMTag.php
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Remove the "HHVM" revision tag from edits and log entries it was applied to.
+ * Based off of ChangeTags::deleteTagEverywhere()
+ * @see bug T75181
+ */
+
+require_once __DIR__ . '/WikimediaMaintenance.php';
+
+class RemoveHHVMTag extends WikimediaMaintenance {
+ public function __construct() {
+ parent::__construct();
+ $this->setBatchSize( 500 );
+ }
+ function execute() {
+ $dbw = wfGetDB( DB_MASTER );
+
+ // delete from valid_tag
+ ChangeTags::undefineTag( 'HHVM' );
+
+ // find out which revisions use this tag, so we can delete from
tag_summary
+ do {
+ $result = $dbw->select(
+ 'change_tag',
+ array( 'ct_rc_id', 'ct_log_id', 'ct_rev_id',
'ct_tag' ),
+ array( 'ct_tag' => 'HHVM' ),
+ __METHOD__,
+ array( 'LIMIT' => $this->mBatchSize )
+ );
+ foreach ( $result as $row ) {
+ if ( $row->ct_rev_id ) {
+ $field = 'ts_rev_id';
+ $fieldValue = $row->ct_rev_id;
+ } elseif ( $row->ct_log_id ) {
+ $field = 'ts_log_id';
+ $fieldValue = $row->ct_log_id;
+ } elseif ( $row->ct_rc_id ) {
+ $field = 'ts_rc_id';
+ $fieldValue = $row->ct_rc_id;
+ } else {
+ // don't know what's up; just skip it
+ continue;
+ }
+
+ // remove the tag from the relevant row of
tag_summary
+ $tsResult = $dbw->selectField( 'tag_summary',
+ 'ts_tags',
+ array( $field => $fieldValue ),
+ __METHOD__ );
+ $tsValues = explode( ',', $tsResult );
+ $tsValues = array_values( array_diff(
$tsValues, array( 'HHVM' ) ) );
+ if ( !$tsValues ) {
+ // no tags left, so delete the row
altogether
+ $dbw->delete( 'tag_summary',
+ array( $field => $fieldValue ),
+ __METHOD__ );
+ } else {
+ $dbw->update( 'tag_summary',
+ array( 'ts_tags' => implode(
',', $tsValues ) ),
+ array( $field => $fieldValue ),
+ __METHOD__ );
+ }
+ }
+ wfWaitForSlaves();
+ } while ( $result->numRows() === $this->mBatchSize );
+
+ // delete from change_tag
+ $dbw->delete( 'change_tag', array( 'ct_tag' => 'HHVM' ),
__METHOD__ );
+
+ // clear the memcache of defined tags
+ ChangeTags::purgeTagCacheAll();
+
+
+ }
+}
+
+$maintClass = 'RemoveHHVMTag';
+require_once RUN_MAINTENANCE_IF_MAIN;
--
To view, visit https://gerrit.wikimedia.org/r/203970
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8b96b8460db3832e9297a07922ee1d9d1af5ccb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaMaintenance
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits