r109878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109877‎ | r109878 | r109879 >
Date:00:20, 24 January 2012
Author:krinkle
Status:ok
Tags:
Comment:
[InterfaceConcurrency] whitespace + missing dependency
* whitespace
* missing dependency (follows-up r108868)
* checking "data.concurrency" as well, could have "data.error" would throw exception for accessing property 'result' of non-object 'undefined'.
Modified paths:
  • /trunk/extensions/InterfaceConcurrency/InterfaceConcurrency.php (modified) (history)
  • /trunk/extensions/InterfaceConcurrency/modules/jquery.interfaceConcurrency/jquery.interfaceConcurrency.js (modified) (history)

Diff [purge]

Index: trunk/extensions/InterfaceConcurrency/InterfaceConcurrency.php
@@ -62,7 +62,7 @@
6363 'scripts' => 'jquery.interfaceConcurrency/jquery.interfaceConcurrency.js',
6464 'dependencies' => array(
6565 'mediawiki.util',
66 - 'mediawiki.user',
 66+ 'user.tokens',
6767 ),
6868 );
6969
Index: trunk/extensions/InterfaceConcurrency/modules/jquery.interfaceConcurrency/jquery.interfaceConcurrency.js
@@ -9,11 +9,11 @@
1010 ccaction: 'checkout',
1111 resourcetype: 'application-specific-string',
1212 record: 123
13 - }, function( result ){
14 - if( result == 'failure' ) {
15 - //checkout failed because item is already checked out. do something useful here.
16 - } else if (result == 'success') {
17 - //successfully checked out item. do something useful here.
 13+ }, function ( result ) {
 14+ if ( result === 'failure' ) {
 15+ // Checkout failed because item is already checked out. do something useful here.
 16+ } else if ( result === 'success' ) {
 17+ // Successfully checked out item. do something useful here.
1818 }
1919 } );
2020 */
@@ -29,20 +29,20 @@
3030 callback: (function) handle results
3131 }
3232 */
33 - check: function( params, callback ) {
 33+ check: function ( params, callback ) {
3434 params = $.extend({
3535 action: 'concurrency',
3636 token: mw.user.tokens.get( 'editToken' ),
3737 format: 'json'
38 - }, params);
 38+ }, params );
3939
4040 return $.ajax( {
4141 type: 'POST',
4242 url: mw.util.wikiScript( 'api' ),
4343 data: params,
44 - success: function( data ){
 44+ success: function ( data ) {
4545 if ( typeof callback === 'function' ){
46 - if ( data && data.concurrency.result ) {
 46+ if ( data && data.concurrency && data.concurrency.result ) {
4747 callback( data.concurrency.result );
4848 }
4949 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108868added js resources for checking in / out resources via concurrency api. load...rmoen22:48, 13 January 2012

Status & tagging log