Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arv: preview arv reports #2031

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TollensWP
Copy link
Contributor

Resolves #671.

Sorry that this diff is hard to read, this change includes a fairly substantial refactor so that the creation of the report wikitext is done on its own rather than coupled with report posting logic. Aside from the obvious, I don't think there are any changes to functionality, other than that curly braces in edit summaries will now be escaped to prevent templates from getting rendered in AN3 reports given that they don't render in edit summaries.

Because of that refactor, it's highly possible this has broken something somewhere (especially considering there's now promise chains involved, which I can only barely wrap my head around): I've done quite a lot of testing to make sure that didn't happen but would appreciate someone double-checking my work, especially with AN3 reporting.

One thing that did come up is that in AN3 reports, the logic for filling the |orig= parameter in the report template seems to be broken (both before my change and after, I think) - I would have fixed it but frankly I don't really understand what should go into that parameter in the first place. The API call is not parsed properly (the following is from the current version):

new mw.Api().get({
action: 'query',
prop: 'revisions',
format: 'json',
rvprop: 'sha1|ids|timestamp|comment',
rvlimit: 100, // intentionally limited
rvstartid: minid,
rvexcludeuser: params.uid,
indexpageids: true,
titles: params.page
}).done(function(data) {
Morebits.wiki.addCheckpoint(); // prevent notification events from causing an erronous "action completed"
// In case an edit summary was revdel'd
var hasHiddenComment = function(rev) {
if (!rev.comment && typeof rev.commenthidden === 'string') {
return '(comment hidden)';
}
return '"' + rev.comment + '"';
};
var orig;
if (data.length) {
var sha1 = data[0].sha1;
for (var i = 1; i < data.length; ++i) {
if (data[i].sha1 === sha1) {
orig = data[i];
break;
}
}
if (!orig) {
orig = data[0];
}
}
var origtext = '';
if (orig) {
origtext = '{{diff2|' + orig.revid + '|' + orig.timestamp + '}} ' + hasHiddenComment(orig);
}

Seems like the data parameter of the callback is trying to be read as an array, but the API call always returns an object. Adding data = data.query.pages[data.query.pageids[0]].revisions; at the start of that callback would convert the object to the array it thinks it is, but I don't know enough about what the |orig= parameter is even for to be able to decide whether that actually fixes the problem. I can't even really create a new ticket because I don't know what the expected behavior is, but if someone is able to explain I can probably fix it pretty easily.

@github-actions github-actions bot added Module: morebits The morebits.js library Module: arv labels Oct 20, 2024
modules/twinklearv.js Fixed Show fixed Hide fixed
modules/twinklearv.js Fixed Show fixed Hide fixed
@TollensWP
Copy link
Contributor Author

Well that's nifty! Never seen that before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: arv Module: morebits The morebits.js library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARV missing previews
1 participant