Skip to content

Commit

Permalink
Apply twinkle change tag to all actions
Browse files Browse the repository at this point in the history
Fairly rote.  Added `summaryAd` to twinkleprotect's `stabilize`, since that was missing it (T247721); didn't do the same for `triage` since while `pagetriageaction` has a `note` parameter that functions like an edit summary we could use, it felt like overkill to add something to morebits just so we can modify `ctx.note` for these largely pointless log entries.  Ideally, https://phabricator.wikimedia.org/T252980 will be taken care of first.  There are a few instances where `setChangeTags` is used earlier than might otherwise be expected, so as to apply to downstream options; a number of these are the `triage` calls, which are thus, as noted, nonfunctional.
  • Loading branch information
Amorymeltzer committed Aug 13, 2020
1 parent c581923 commit 1796819
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 88 deletions.
3 changes: 2 additions & 1 deletion modules/friendlyshared.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ Twinkle.shared.callbacks = {

var summaryText = 'Added {{[[Template:' + params.template + '|' + params.template + ']]}} template.';
pageobj.setPageText(text + pageText);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setMinorEdit(Twinkle.getPref('markSharedIPAsMinor'));
pageobj.setCreateOption('recreate');
pageobj.save();
Expand Down
23 changes: 14 additions & 9 deletions modules/friendlytag.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,12 +1194,12 @@ Twinkle.tag.callbacks = {
}

// avoid truncated summaries
if (summaryText.length > (499 - Twinkle.getPref('summaryAd').length)) {
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
}

pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summaryText);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
Expand All @@ -1211,7 +1211,8 @@ Twinkle.tag.callbacks = {
talkpageText += params.mergeReason.trim() + ' ~~~~';
var talkpage = new Morebits.wiki.page('Talk:' + params.discussArticle, 'Posting rationale on talk page');
talkpage.setAppendText(talkpageText);
talkpage.setEditSummary('/* ' + params.talkDiscussionTitle + ' */ new section' + Twinkle.getPref('summaryAd'));
talkpage.setEditSummary('/* ' + params.talkDiscussionTitle + ' */ new section');
talkpage.setChangeTags(Twinkle.changeTags);
talkpage.setWatchlist(Twinkle.getPref('watchMergeDiscussions'));
talkpage.setCreateOption('recreate');
talkpage.append();
Expand All @@ -1235,6 +1236,7 @@ Twinkle.tag.callbacks = {
};
var otherpage = new Morebits.wiki.page(params.mergeTarget, 'Tagging other page (' +
params.mergeTarget + ')');
otherpage.setChangeTags(Twinkle.changeTags);
otherpage.setCallbackParameters(newParams);
otherpage.load(Twinkle.tag.callbacks.article);
}
Expand Down Expand Up @@ -1269,7 +1271,8 @@ Twinkle.tag.callbacks = {
return;
}
pageobj.setPageText(text);
pageobj.setEditSummary(summary + ' [[:' + Morebits.pageNameNorm + ']]' + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summary + ' [[:' + Morebits.pageNameNorm + ']]');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('recreate');
pageobj.save();
});
Expand All @@ -1290,8 +1293,8 @@ Twinkle.tag.callbacks = {
'{{subst:uw-notenglish|1=' + Morebits.pageNameNorm +
(params.translationPostAtPNT ? '' : '|nopnt=yes') + '}} ~~~~';
userTalkPage.setAppendText(notifytext);
userTalkPage.setEditSummary('Notice: Please use English when contributing to the English Wikipedia.' +
Twinkle.getPref('summaryAd'));
userTalkPage.setEditSummary('Notice: Please use English when contributing to the English Wikipedia.');
userTalkPage.setChangeTags(Twinkle.changeTags);
userTalkPage.setCreateOption('recreate');
userTalkPage.setFollowRedirect(true, false);
userTalkPage.append();
Expand Down Expand Up @@ -1707,12 +1710,12 @@ Twinkle.tag.callbacks = {
summaryText += (tags.length > 0 ? ' tag' + (tags.length > 1 ? 's' : ' ') : 'rcat shell') + ' to redirect';

// avoid truncated summaries
if (summaryText.length > (499 - Twinkle.getPref('summaryAd').length)) {
if (summaryText.length > 499) {
summaryText = summaryText.replace(/\[\[[^|]+\|([^\]]+)\]\]/g, '$1');
}

pageobj.setPageText(pageText);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summaryText);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
Expand Down Expand Up @@ -1812,7 +1815,8 @@ Twinkle.tag.callbacks = {
}

pageobj.setPageText(text);
pageobj.setEditSummary(summary.substring(0, summary.length - 2) + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summary.substring(0, summary.length - 2));
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchTaggedPages'));
pageobj.setMinorEdit(Twinkle.getPref('markTaggedPagesAsMinor'));
pageobj.setCreateOption('nocreate');
Expand Down Expand Up @@ -1997,6 +2001,7 @@ Twinkle.tag.callback.evaluate = function friendlytagCallbackEvaluate(e) {

var wikipedia_page = new Morebits.wiki.page(Morebits.pageNameNorm, 'Tagging ' + Twinkle.tag.mode);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipedia_page.load(Twinkle.tag.callbacks[Twinkle.tag.mode]);

};
Expand Down
10 changes: 5 additions & 5 deletions modules/friendlytalkback.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,25 +363,25 @@ Twinkle.talkback.evaluate = function(e) {

switch (input.tbtarget) {
case 'notice':
talkpage.setEditSummary(Twinkle.talkback.noticeboards[input.noticeboard].editSummary + Twinkle.getPref('summaryAd'));
talkpage.setEditSummary(Twinkle.talkback.noticeboards[input.noticeboard].editSummary);
break;
case 'mail':
talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref('summaryAd'));
talkpage.setEditSummary("Notification: You've got mail");
break;
case 'see':
talkpage.setEditSummary('Please check the discussion at [[:' + input.page +
(input.section ? '#' + input.section : '') + ']]' + Twinkle.getPref('summaryAd'));
(input.section ? '#' + input.section : '') + ']]');
break;
default: // tbtarget one of mytalk, usertalk, other
var editSummary = 'Talkback ([[:';
if (input.tbtarget !== 'other' && !/^\s*user talk:/i.test(input.page)) {
editSummary += 'User talk:';
}
editSummary += input.page + (input.section ? '#' + input.section : '') + ']])';
talkpage.setEditSummary(editSummary + Twinkle.getPref('summaryAd'));
talkpage.setEditSummary(editSummary + input.page + (input.section ? '#' + input.section : '') + ']])');
}

talkpage.setAppendText('\n\n' + Twinkle.talkback.getNoticeWikitext(input));
talkpage.setChangeTags(Twinkle.changeTags);
talkpage.setCreateOption('recreate');
talkpage.setMinorEdit(Twinkle.getPref('markTalkbackAsMinor'));
talkpage.setFollowRedirect(true);
Expand Down
3 changes: 2 additions & 1 deletion modules/friendlywelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ Twinkle.welcome.callbacks = {

var summaryText = 'Welcome to Wikipedia!';
pageobj.setPageText(text);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary(summaryText);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchWelcomes'));
pageobj.setCreateOption('recreate');
pageobj.save();
Expand Down
20 changes: 13 additions & 7 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ Twinkle.arv.callback.evaluate = function(e) {
}

aivPage.getStatusElement().status('Adding new report...');
aivPage.setEditSummary('Reporting [[Special:Contributions/' + uid + '|' + uid + ']].' + Twinkle.getPref('summaryAd'));
aivPage.setEditSummary('Reporting [[Special:Contributions/' + uid + '|' + uid + ']].');
aivPage.setChangeTags(Twinkle.changeTags);
aivPage.setAppendText('\n*{{' + (mw.util.isIPAddress(uid) ? 'IPvandal' : 'vandal') + '|' + (/=/.test(uid) ? '1=' : '') + uid + '}} – ' + reason);
aivPage.append();
});
Expand Down Expand Up @@ -601,7 +602,8 @@ Twinkle.arv.callback.evaluate = function(e) {
return;
}
uaaPage.getStatusElement().status('Adding new report...');
uaaPage.setEditSummary('Reporting [[Special:Contributions/' + uid + '|' + uid + ']].' + Twinkle.getPref('summaryAd'));
uaaPage.setEditSummary('Reporting [[Special:Contributions/' + uid + '|' + uid + ']].');
uaaPage.setChangeTags(Twinkle.changeTags);
uaaPage.setPageText(text + '\n' + reason);
uaaPage.save();
});
Expand Down Expand Up @@ -776,13 +778,14 @@ Twinkle.arv.processSock = function(params) {
// notify all user accounts if requested
if (params.notify && params.sockpuppets.length > 0) {

var notifyEditSummary = 'Notifying about suspicion of sockpuppeteering.' + Twinkle.getPref('summaryAd');
var notifyEditSummary = 'Notifying about suspicion of sockpuppeteering.';
var notifyText = '\n\n{{subst:socksuspectnotice|1=' + params.uid + '}} ~~~~';

// notify user's master account
var masterTalkPage = new Morebits.wiki.page('User talk:' + params.uid, 'Notifying suspected sockpuppeteer');
masterTalkPage.setFollowRedirect(true);
masterTalkPage.setEditSummary(notifyEditSummary);
masterTalkPage.setChangeTags(Twinkle.changeTags);
masterTalkPage.setAppendText(notifyText);
masterTalkPage.append();

Expand All @@ -807,6 +810,7 @@ Twinkle.arv.processSock = function(params) {
var sockTalkPage = new Morebits.wiki.page('User talk:' + socks[i], 'Notification for ' + socks[i]);
sockTalkPage.setFollowRedirect(true);
sockTalkPage.setEditSummary(notifyEditSummary);
sockTalkPage.setChangeTags(Twinkle.changeTags);
sockTalkPage.setAppendText(notifyText);
sockTalkPage.append(onSuccess);
}
Expand All @@ -830,7 +834,8 @@ Twinkle.arv.processSock = function(params) {

var spiPage = new Morebits.wiki.page(reportpage, 'Retrieving discussion page');
spiPage.setFollowRedirect(true);
spiPage.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].' + Twinkle.getPref('summaryAd'));
spiPage.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].');
spiPage.setChangeTags(Twinkle.changeTags);
spiPage.setAppendText(text);
switch (Twinkle.getPref('spiWatchReport')) {
case 'yes':
Expand Down Expand Up @@ -967,18 +972,19 @@ Twinkle.arv.processAN3 = function(params) {

var an3Page = new Morebits.wiki.page(reportpage, 'Retrieving discussion page');
an3Page.setFollowRedirect(true);
an3Page.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].' + Twinkle.getPref('summaryAd'));
an3Page.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].');
an3Page.setChangeTags(Twinkle.changeTags);
an3Page.setAppendText(text);
an3Page.append();

// notify user

var notifyEditSummary = 'Notifying about edit warring noticeboard discussion.' + Twinkle.getPref('summaryAd');
var notifyText = '\n\n{{subst:an3-notice|1=' + mw.util.wikiUrlencode(params.uid) + '|auto=1}} ~~~~';

var talkPage = new Morebits.wiki.page('User talk:' + params.uid, 'Notifying edit warrior');
talkPage.setFollowRedirect(true);
talkPage.setEditSummary(notifyEditSummary);
talkPage.setEditSummary('Notifying about edit warring noticeboard discussion.');
talkPage.setChangeTags(Twinkle.changeTags);
talkPage.setAppendText(notifyText);
talkPage.append();
Morebits.wiki.removeCheckpoint(); // all page updates have been started
Expand Down
18 changes: 12 additions & 6 deletions modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu
var wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting page ' + pageName);
wikipedia_page.setCallbackParameters(params);
if (input.delete_page) {
wikipedia_page.setEditSummary(input.reason + Twinkle.getPref('deletionSummaryAd'));
wikipedia_page.setEditSummary(input.reason);
wikipedia_page.setChangeTags(Twinkle.changeTags);
wikipedia_page.suppressProtectWarning();
wikipedia_page.deletePage(Twinkle.batchdelete.callbacks.doExtras, pageDeleter.workerFailure);
} else {
Expand All @@ -492,7 +493,8 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu

var wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting subpage ' + pageName);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setEditSummary(input.reason + Twinkle.getPref('deletionSummaryAd'));
wikipedia_page.setEditSummary(input.reason);
wikipedia_page.setChangeTags(Twinkle.changeTags);
wikipedia_page.suppressProtectWarning();
wikipedia_page.deletePage(Twinkle.batchdelete.callbacks.doExtras, pageDeleter.workerFailure);
});
Expand Down Expand Up @@ -581,7 +583,8 @@ Twinkle.batchdelete.callbacks = {
redirectDeleter.setPageList(pages);
redirectDeleter.run(function(pageName) {
var wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting ' + pageName);
wikipedia_page.setEditSummary('[[WP:CSD#G8|G8]]: Redirect to deleted page "' + apiobj.params.page + '"' + Twinkle.getPref('deletionSummaryAd'));
wikipedia_page.setEditSummary('[[WP:CSD#G8|G8]]: Redirect to deleted page "' + apiobj.params.page + '"');
wikipedia_page.setChangeTags(Twinkle.changeTags);
wikipedia_page.deletePage(redirectDeleter.workerSuccess, redirectDeleter.workerFailure);
});
},
Expand All @@ -595,7 +598,8 @@ Twinkle.batchdelete.callbacks = {
}

var page = new Morebits.wiki.page(apiobj.params.talkPage, 'Deleting talk page of article ' + apiobj.params.page);
page.setEditSummary('[[WP:CSD#G8|G8]]: [[Help:Talk page|Talk page]] of deleted page "' + apiobj.params.page + '"' + Twinkle.getPref('deletionSummaryAd'));
page.setEditSummary('[[WP:CSD#G8|G8]]: [[Help:Talk page|Talk page]] of deleted page "' + apiobj.params.page + '"');
page.setChangeTags(Twinkle.changeTags);
page.deletePage();
},
unlinkBacklinksMain: function(apiobj) {
Expand Down Expand Up @@ -643,7 +647,8 @@ Twinkle.batchdelete.callbacks = {
params.unlinker.workerSuccess(pageobj);
return;
}
pageobj.setEditSummary('Removing link(s) to deleted page ' + params.page + Twinkle.getPref('deletionSummaryAd'));
pageobj.setEditSummary('Removing link(s) to deleted page ' + params.page);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setPageText(text);
pageobj.setCreateOption('nocreate');
pageobj.setMaxConflictRetries(10);
Expand Down Expand Up @@ -695,7 +700,8 @@ Twinkle.batchdelete.callbacks = {
params.unlinker.workerFailure(pageobj);
return;
}
pageobj.setEditSummary('Removing instance of file ' + image + ' that has been deleted because "' + params.reason + '")' + Twinkle.getPref('deletionSummaryAd'));
pageobj.setEditSummary('Removing instance of file ' + image + ' that has been deleted because "' + params.reason + '")');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setPageText(text);
pageobj.setCreateOption('nocreate');
pageobj.setMaxConflictRetries(10);
Expand Down
1 change: 1 addition & 0 deletions modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ Twinkle.batchprotect.callbacks = {
}

page.setEditSummary(apiobj.params.reason);
page.setChangeTags(Twinkle.changeTags);
page.protect(apiobj.params.batchOperation.workerSuccess, apiobj.params.batchOperation.workerFailure);
}
};
Expand Down
6 changes: 4 additions & 2 deletions modules/twinklebatchundelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ Twinkle.batchundelete.callback.evaluate = function(event) {

var wikipedia_page = new Morebits.wiki.page(pageName, 'Undeleting page ' + pageName);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setEditSummary(input.reason + Twinkle.getPref('deletionSummaryAd'));
wikipedia_page.setEditSummary(input.reason);
wikipedia_page.setChangeTags(Twinkle.changeTags);
wikipedia_page.suppressProtectWarning();
wikipedia_page.setMaxRetries(3); // temporary increase from 2 to make batchundelete more likely to succeed [[phab:T222402]] #613
wikipedia_page.undeletePage(Twinkle.batchundelete.callbacks.doExtras, pageUndeleter.workerFailure);
Expand Down Expand Up @@ -196,7 +197,8 @@ Twinkle.batchundelete.callbacks = {
}

var page = new Morebits.wiki.page(apiobj.params.talkPage, 'Undeleting talk page of ' + apiobj.params.page);
page.setEditSummary('Undeleting [[Help:Talk page|talk page]] of "' + apiobj.params.page + '"' + Twinkle.getPref('deletionSummaryAd'));
page.setEditSummary('Undeleting [[Help:Talk page|talk page]] of "' + apiobj.params.page + '"');
page.setChangeTags(Twinkle.changeTags);
page.undeletePage();
}
};
Expand Down
5 changes: 4 additions & 1 deletion modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,9 @@ Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) {
}
blockoptions.reblock = 1; // Writing over a block will fail otherwise
}

// execute block
blockoptions.tags = Twinkle.changeTags;
blockoptions.token = mw.user.tokens.get('csrfToken');
var mbApi = new Morebits.wiki.api('Executing block', blockoptions, function() {
statusElement.info('Completed');
Expand Down Expand Up @@ -1671,10 +1673,11 @@ Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) {
if (messageData.suppressArticleInSummary !== true && params.article) {
summary += ' on [[:' + params.article + ']]';
}
summary += '.' + Twinkle.getPref('summaryAd');
summary += '.';

pageobj.setPageText(text);
pageobj.setEditSummary(summary);
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('watchWarnings'));
pageobj.save();
};
Expand Down
3 changes: 2 additions & 1 deletion modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,8 @@ Twinkle.config.writePrefs = function twinkleconfigWritePrefs(pageobj) {
'// End of twinkleoptions.js\n';

pageobj.setPageText(text);
pageobj.setEditSummary('Saving Twinkle preferences: automatic edit from [[:' + Morebits.pageNameNorm + ']] ([[WP:TW|TW]])');
pageobj.setEditSummary('Saving Twinkle preferences: automatic edit from [[:' + Morebits.pageNameNorm + ']]');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('recreate');
pageobj.save(Twinkle.config.saveSuccess);
};
Expand Down
9 changes: 6 additions & 3 deletions modules/twinkledeprod.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ var callback_commit = function(event) {
wikipedia_api.post();

var page = new Morebits.wiki.page(pageName, 'Deleting article ' + pageName);
page.setEditSummary('Expired [[WP:PROD|PROD]], concern was: ' + concerns[pageName] + Twinkle.getPref('deletionSummaryAd'));
page.setEditSummary('Expired [[WP:PROD|PROD]], concern was: ' + concerns[pageName]);
page.setChangeTags(Twinkle.changeTags);
page.suppressProtectWarning();
page.deletePage(batchOperation.workerSuccess, batchOperation.workerFailure);
});
Expand All @@ -168,15 +169,17 @@ var callback_commit = function(event) {
}

var page = new Morebits.wiki.page('Talk:' + apiobj.params.page, 'Deleting talk page of article ' + apiobj.params.page);
page.setEditSummary('[[WP:CSD#G8|G8]]: [[Help:Talk page|Talk page]] of deleted page "' + apiobj.params.page + '"' + Twinkle.getPref('deletionSummaryAd'));
page.setEditSummary('[[WP:CSD#G8|G8]]: [[Help:Talk page|Talk page]] of deleted page "' + apiobj.params.page + '"');
page.setChangeTags(Twinkle.changeTags);
page.deletePage();
},
callback_deleteRedirects = function(apiobj) {
var $doc = $(apiobj.responseXML);
$doc.find('redirects rd').each(function() {
var title = $(this).attr('title');
var page = new Morebits.wiki.page(title, 'Deleting redirecting page ' + title);
page.setEditSummary('[[WP:CSD#G8|G8]]: Redirect to deleted page "' + apiobj.params.page + '"' + Twinkle.getPref('deletionSummaryAd'));
page.setEditSummary('[[WP:CSD#G8|G8]]: Redirect to deleted page "' + apiobj.params.page + '"');
page.setChangeTags(Twinkle.changeTags);
page.deletePage();
});
};
Expand Down
Loading

0 comments on commit 1796819

Please sign in to comment.