r93063 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93062‎ | r93063 | r93064 >
Date:16:54, 25 July 2011
Author:diebuche
Status:reverted (Comments)
Tags:
Comment:
mw.user.js: Make sessionId public
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.user.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.user.js
@@ -29,7 +29,7 @@
3030 *
3131 * @return String: Random set of 32 alpha-numeric characters
3232 */
33 - function generateId() {
 33+ this.generateId = function() {
3434 var id = '';
3535 var seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
3636 for ( var i = 0, r; i < 32; i++ ) {
@@ -37,7 +37,7 @@
3838 id += seed.substring( r, r + 1 );
3939 }
4040 return id;
41 - }
 41+ };
4242
4343 /**
4444 * Gets the current user's name.
@@ -68,7 +68,7 @@
6969 this.sessionId = function () {
7070 var sessionId = $.cookie( 'mediaWiki.user.sessionId' );
7171 if ( typeof sessionId == 'undefined' || sessionId === null ) {
72 - sessionId = generateId();
 72+ sessionId = that.generateId();
7373 $.cookie( 'mediaWiki.user.sessionId', sessionId, { 'expires': null, 'path': '/' } );
7474 }
7575 return sessionId;
@@ -90,7 +90,7 @@
9191 }
9292 var id = $.cookie( 'mediaWiki.user.id' );
9393 if ( typeof id == 'undefined' || id === null ) {
94 - id = generateId();
 94+ id = that.generateId();
9595 }
9696 // Set cookie if not set, or renew it if already set
9797 $.cookie( 'mediaWiki.user.id', id, { 'expires': 365, 'path': '/' } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96236Revert r93063 per r93063 CRkrinkle16:50, 4 September 2011
r96237Add local generator function to account for revert of r93063 in r96236.krinkle17:04, 4 September 2011

Comments

#Comment by Krinkle (talk | contribs)   23:07, 25 July 2011

Why make this public ? The current user's ID should be available through mw.user.sessionId().

Where would you use generateId() for directly ?

#Comment by Krinkle (talk | contribs)   12:02, 3 August 2011

Ping.

#Comment by DieBuche (talk | contribs)   12:48, 3 August 2011

It's used in ajaxCats as a random number generator. I figured I don't need to duplicate that functionality. L876

#Comment by Krinkle (talk | contribs)   11:37, 11 August 2011

Please don't reuse methods for a different purpose.

mw.user.generateId() is not a random number generator.

#Comment by Hashar (talk | contribs)   09:46, 14 August 2011

removing '1.18' tag since this is probably going to be rewritten / reverted.

Status & tagging log