r111695 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111694‎ | r111695 | r111696 >
Date:22:51, 16 February 2012
Author:catrope
Status:ok
Tags:
Comment:
Since I'm sick of all the mw.user-induced problems, break the dependency between mw.user.{options,tokens} and mw.user . With this change, mediawiki.js defines a skeleton object for mw.user containing just the options and tokens maps, and mediawiki.user.js copies those when it sets up the full mw.user object. This way of doing extending is kind of ugly but I don't have time to work on something nicer without breaking backwards compatibility. Because mw.user.{options,tokens} are loaded very early, this also means they're now guaranteed to be available to everything everywhere.
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.user.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
@@ -85,11 +85,4 @@
8686 public function getGroup() {
8787 return 'private';
8888 }
89 -
90 - /**
91 - * @return array
92 - */
93 - public function getDependencies() {
94 - return array( 'mediawiki.user' );
95 - }
9689 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php
@@ -60,11 +60,4 @@
6161 public function getGroup() {
6262 return 'private';
6363 }
64 -
65 - /**
66 - * @return array
67 - */
68 - public function getDependencies() {
69 - return array( 'mediawiki.user' );
70 - }
7164 }
Index: trunk/phase3/resources/mediawiki/mediawiki.user.js
@@ -7,7 +7,7 @@
88 /**
99 * User object
1010 */
11 - function User() {
 11+ function User( options, tokens ) {
1212
1313 /* Private Members */
1414
@@ -15,9 +15,9 @@
1616
1717 /* Public Members */
1818
19 - this.options = new mw.Map();
 19+ this.options = options || new mw.Map();
2020
21 - this.tokens = new mw.Map();
 21+ this.tokens = tokens || new mw.Map();
2222
2323 /* Public Methods */
2424
@@ -176,6 +176,8 @@
177177 };
178178 }
179179
180 - mw.user = new User();
 180+ // Extend the skeleton mw.user from mediawiki.js
 181+ // This is kind of ugly but we're stuck with this for b/c reasons
 182+ mw.user = new User( mw.user.options, mw.user.tokens );
181183
182184 })(jQuery);
\ No newline at end of file
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -1419,7 +1419,13 @@
14201420 return s;
14211421 }
14221422 };
1423 - }() )
 1423+ }() ),
 1424+
 1425+ // Skeleton user object. mediawiki.user.js extends this
 1426+ user: {
 1427+ options: new Map(),
 1428+ tokens: new Map()
 1429+ }
14241430 };
14251431
14261432 })( jQuery );

Sign-offs

UserFlagDate
Nikerabbitinspected07:16, 17 February 2012
Werdnainspected18:19, 17 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111699MFT r111695, r111697reedy23:02, 16 February 2012
r112027MFT r111580, r111695, r111697, r111832, r112021reedy17:29, 21 February 2012

Status & tagging log