-
Notifications
You must be signed in to change notification settings - Fork 152
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
batchundelete: Improvements to morebits.wiki.page, short- and long-term alleviation of #613, color like batchdelete #616
Conversation
cc @MusikAnimal I mentioned this at #601 (comment) to @siddharthvp but I'd like to merge this sooner rather than later to get deal with |
ctx.onUndeleteFailure = onFailure || emptyFunction; | ||
|
||
// if a non-admin tries to do this, don't bother | ||
if (!Morebits.userIsInGroup('sysop')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would unnecessarily slow down the code in batchundelete. Better to put this in fnProcessUndeleteError
. No decently written script would show an undelete button to non-admins anyway.
This would apply to deletePage function also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this backwards? Failing here means non-sysop don't do the later protection query. At any rate, it's quite quick as is (although admittedly slowing things down isn't bad in our current situation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, this would slow down the code for sysops. Yes, it would speed up things a great deal for non-sysops but what good is that since they won't be able to undelete anything after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would guess the impetus was to allow for the "retrieving undelete token..." message?
// Everything except watching and patrolling should eventually | ||
// use csrf, but until then (#615) the stupid hack below | ||
// should work for undeletion | ||
if (fnCanUseMwUserToken('undelete')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, token = mw.user.tokens.get('editToken');
is being used whether or not this condition is true. Why have this condition at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I was trying to convey in the comment: until I can radically modernize the handling of tokens, I wanted to keep the code structure parallel. I think it's easier to understand and fix/remove/rewrite if as much as possible follows a similar, understandable pathway rather than a bespoke system for each. Yes, we can remove this fnCanUseMwUserToken
, I suppose that'd be fine given the context of the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh duh! If suppressProtectWarning
isn't set, the pages fail the "poor man's normalisation" in fnCanUseMwUserToken
. suppressProtectWarning
is set for the batch but not for talkpages so the kludge was only reached (in this case) for talk pages. This matches the behavior in twinklebatchdelete
, and is required; since the batches check, display, and confirm on protection status for the pages listed (well, now batchundelete
does) it's not needed for those, but the confirms(s) are needed for any talkpages found later. Sorry for leading you on @siddharthvp, I knew this a few days ago but Morebits
gets confusing!
As far as fnCanUseMwUserToken
goes, followRedirect
doesn't really make sense for undeletePage
so the suppressProtectWarning
is the real killer. The real goal of that whole thing seems to be to avoid another API call to get the protection status if suppressProtectWarning
isn't set, none of that is relevant for batch-processing like this. I'm inclined to leave it as is for now on the off chance we decide to use it elsewhere before revamping morebits
, as well as, as mentioned elsewhere, making what will surely be an revamping process easier.
I'm not sure if querying for deleted revisions of talk page, and then undeleting if they exist is a good idea, as this is a lot of extra API calls. What about doing it like this: store the list of pages whose undeletion was successful, in an array, and then use a separate batch operation to restore the talks. For this batch-op, unset the How is this handled in batchdelete? Is a status line shown only for the main pages, or for talk pages and redirects too? |
f4b189e
to
4f85861
Compare
As I'm writing this, I'm realizing that the check for ETA: Eh, I'm reconsidering this (the latter bit) in favor of the old way (only restoring if the page doesn't exist). Anything else might be too surprising and is beyond the scope of what I had initially attempted to do here. I edited |
247ad3c
to
2a5e111
Compare
Basically just copy the stuff for deletePage, less following redirects. deletePage was added in 4b92869 along with move, but unlike protect (68132e5) delete and undelete are one-way streets. Uses a dumb kludge to get around the lack of a proper token until we can rewrite the token handling stuff in `morebits` (wikimedia-gadgets#615).
Added in prior commit (3b0f12e). Some testing suggests this helps a bit with wikimedia-gadgets#613, but regardless, it's clearer this way anyway.
… and alleviate wikimedia-gadgets#613 Increase from 2 to 3, makes `twinklebatchundelete` much more likely to succeed until https://phabricator.wikimedia.org/T222402 can be dealt with. We've been handling `internal_api_error_DBQueryError` for deletion since wikimedia-gadgets#198, before even `batchOperation` was added (ecfff3b).
2a5e111
to
a738d5b
Compare
Follows up on wikimedia-gadgets#601. Allows for a better, more clear message when listing deletions, as well as more full error handling and clearer code. Easier to expand, should we desire.
…ges a la batchdelete
a738d5b
to
a147427
Compare
Thanks, that makes a lot of sense and also makes my point moot, as my suggested method also would have ended up restoring deleted edits at existing talk pages. |
We need to migrate our token usage properly (wikimedia-gadgets#615, noted in wikimedia-gadgets#616) but one simple step is moving from `mw.user.tokens.get('editToken')` to `mw.user.tokens.get('csrfToken')`. Using `csrfToken` in favor of `editToken` was done back in 2015/2016 with the move away from `action=tokens` to `meta=tokens`. Both `editToken` and `csrfToken` have been provided in the `mw.user.tokens` object for quite some time, and the former is finally being deprecated (see [T233442](https://phabricator.wikimedia.org/T233442)). The presence of the `edittoken` attribute in xml responses is unchanged.
…tokens Deprecated ages ago (see https://www.mediawiki.org/wiki/MediaWiki_1.24#API_changes and https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/153110/). Closes wikimedia-gadgets#615. Use `curtimestamp` on `.load` calls now that we no longer use `intoken`. As noted in wikimedia-gadgets#741, `starttimestamp` was only available because we were still using the outdated `intoken` method. With that gone, we need to explicitly provide `query.curtimestamp`, thus replicating the loading timestamp that we can feed it into `starttimestamp` and avoid edit conflicts. Also replaced `intoken` in `twinklefluff.js` and removed the undelete kludge from wikimedia-gadgets#616. Some references to token names in error messages are kept for ease of debugging.
…tokens Deprecated ages ago (see https://www.mediawiki.org/wiki/MediaWiki_1.24#API_changes and https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/153110/). Closes wikimedia-gadgets#615. Use `curtimestamp` on `.load` calls now that we no longer use `intoken`. As noted in wikimedia-gadgets#741, `starttimestamp` was only available because we were still using the outdated `intoken` method. With that gone, we need to explicitly provide `query.curtimestamp`, thus replicating the loading timestamp that we can feed it into `starttimestamp` and avoid edit conflicts. Also replaced `intoken` in `twinklefluff.js` and removed the undelete kludge from wikimedia-gadgets#616. Some references to token names in error messages are kept for ease of debugging.
tl;dr — Add
undeletePage
toMorebits.wiki.page
, use it intwinklebatchundelete
(helps with #613), bumpmaxRetries
(helps with #613), restructure talkpage undeletion (from #601), and add red color for fully create protected pages.Basically just copy the stuff for deletePage, less following redirects. deletePage was added in 4b92869 along with move, but unlike protect (68132e5) delete and undelete are one-way streets. Uses a dumb kludge to get around the lack of a proper token until we can rewrite the token handling stuff in
morebits
(morebits: Modernize token handling #615).Added in prior commit (47c9cf9). Some testing suggests this helps a bit with Batch undelete mostly unsuccessful for large numbers of undeletions #613, but regardless, it's clearer this way anyway.
Increase from 2 to 3, makes
twinklebatchundelete
much more likely to succeed until phabricator.wikimedia.org/T222402 can be dealt with. We've been handlinginternal_api_error_DBQueryError
for deletion since morebits: while deleting, retry on DBQueryError #198, before evenbatchOperation
was added (ecfff3b).Follows up on batchundelete: restore talk pages too #601. Allows for a better, more clear message when listing deletions, as well as more full error handling and clearer code. Easier to expand, should we desire.