-
Notifications
You must be signed in to change notification settings - Fork 143
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
Use server time rather than client time wherever possible #741
Merged
Amorymeltzer
merged 3 commits into
wikimedia-gadgets:master
from
siddharthvp:noclientclock
Jan 7, 2020
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -705,7 +705,7 @@ Twinkle.xfd.callbacks = { | |
wikipedia_page.load(Twinkle.xfd.callbacks.afd.discussionPage); | ||
|
||
// Today's list | ||
var date = new Date(); | ||
var date = new Date(pageobj.getLoadTime()); | ||
wikipedia_page = new Morebits.wiki.page('Wikipedia:Articles for deletion/Log/' + date.getUTCFullYear() + ' ' + | ||
date.getUTCMonthName() + ' ' + date.getUTCDate(), "Adding discussion to today's list"); | ||
wikipedia_page.setFollowRedirect(true); | ||
|
@@ -982,7 +982,7 @@ Twinkle.xfd.callbacks = { | |
var params = pageobj.getCallbackParameters(); | ||
var statelem = pageobj.getStatusElement(); | ||
|
||
var date = new Date(); | ||
var date = new Date(pageobj.getLoadTime()); | ||
var date_header = '===' + date.getUTCMonthName() + ' ' + date.getUTCDate() + ', ' + date.getUTCFullYear() + '===\n'; | ||
var date_header_regex = new RegExp('(===\\s*' + date.getUTCMonthName() + '\\s+' + date.getUTCDate() + ',\\s+' + date.getUTCFullYear() + '\\s*===)'); | ||
var new_data = '{{subst:mfd3|pg=' + Morebits.pageNameNorm + params.numbering + '}}'; | ||
|
@@ -1232,7 +1232,8 @@ Twinkle.xfd.callbacks = { | |
var query = { | ||
'action': 'query', | ||
'titles': mw.config.get('wgPageName'), | ||
'redirects': true | ||
'redirects': true, | ||
'curtimestamp': true | ||
}; | ||
var wikipedia_api = new Morebits.wiki.api('Finding target of redirect', query, Twinkle.xfd.callbacks.rfd.findTargetCallback(callback)); | ||
wikipedia_api.params = params; | ||
|
@@ -1242,20 +1243,22 @@ Twinkle.xfd.callbacks = { | |
// This is a closure for the callback from the above API request, which gets the target of the redirect | ||
findTargetCallback: function(callback) { | ||
return function(apiobj) { | ||
var xmlDoc = apiobj.responseXML; | ||
var target = $(xmlDoc).find('redirects r').first().attr('to'); | ||
var $xmlDoc = $(apiobj.responseXML); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting that elsewhere in |
||
var curtimestamp = $xmlDoc.find('api').attr('curtimestamp'); | ||
var target = $xmlDoc.find('redirects r').first().attr('to'); | ||
if (!target) { | ||
apiobj.statelem.error('This page is currently not a redirect, aborting'); | ||
return; | ||
} | ||
var section = $xmlDoc.find('redirects r').first().attr('tofragment'); | ||
apiobj.params.curtimestamp = curtimestamp; | ||
apiobj.params.target = target; | ||
var section = $(xmlDoc).find('redirects r').first().attr('tofragment'); | ||
apiobj.params.section = section; | ||
callback(apiobj.params); | ||
}; | ||
}, | ||
main: function(params) { | ||
var date = new Date(); | ||
var date = new Date(params.curtimestamp); | ||
params.logpage = 'Wikipedia:Redirects for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate(); | ||
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm; | ||
|
||
|
@@ -1398,7 +1401,7 @@ Twinkle.xfd.callback.evaluate = function(e) { | |
} | ||
|
||
var query, wikipedia_page, wikipedia_api, logpage, params; | ||
var date = new Date(); | ||
var date = new Date(); // XXX: avoid use of client clock, still used by TfD, FfD and CfD | ||
switch (type) { | ||
|
||
case 'afd': // AFD | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎉 Yes, much better!