Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#15289 closed defect (fixed)

syncMode: true leads to "rpcConfig is not defined"

Reported by: Primus Owned by: haysmark
Priority: high Milestone: 1.8
Component: DojoX Data Version: 1.6.0
Keywords: Cc:
Blocked By: Blocking:

Description

When you create a JsonRestStore? and specify a syncMode: true attribute, this leads to a "rpcConfig is not defined" error when you try to save new items in the store.

I tracked the bug to line nr 347 in dojox/data/JsonRestStore.js.

Originally (Dojo 1.7.2) this line reads :

rpcConfig._sync = true;

This needs to be changed to :

dojox.rpc._sync = true;

rpcConfig is not configured anywhere, maybe this was renamed in some old version. Changing it to the line I mentioned above seems to fix the problem.

Attachments (1)

15289.patch (798 bytes) - added by haysmark 7 years ago.
Add dojox dep.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by haysmark

Milestone: tbd1.8
Owner: changed from Kris Zyp to haysmark
Status: newassigned

comment:2 Changed 7 years ago by haysmark

Resolution: fixed
Status: assignedclosed

In [29061]:

Remove reference to undefined global. Fixes #15289.

comment:3 Changed 7 years ago by ben hockey

Resolution: fixed
Status: closedreopened

need to add a dependency (probably "dojox") to get a handle to dojox.rpc rather than accessing it as a global

Changed 7 years ago by haysmark

Attachment: 15289.patch added

Add dojox dep.

comment:4 in reply to:  3 Changed 7 years ago by haysmark

Replying to neonstalwart:

need to add a dependency (probably "dojox") to get a handle to dojox.rpc rather than accessing it as a global

I attached a patch, is this what you meant? Besides adding the dojox dep, I noticed in dojox.rpc that people were calling getObject to ensure dojox.rpc existed.

comment:5 Changed 7 years ago by haysmark

Priority: undecidedhigh

comment:6 Changed 7 years ago by ben hockey

that looks right... you could possibly use the return value from lang.getObject if you wanted to

define(['dojox', ...], function (dojox, ...) {
  var rpc = lang.getObject('rpc', true, dojox);

  // ...

    // at the appropriate place in the code
    rpc._sync = true;
}

or an alternative that doesn't use the dojox dep is:

define([...], function (...) {
  var rpc = lang.getObject('dojox.rpc', true);

  // ...

    // at the appropriate place in the code
    rpc._sync = true;
}

the reason for needing to do this is because the "dojox" global variable can be remapped to a different name so you can't rely on a global reference. by pulling dojox in as a dependency, we are using the locally scoped variable dojox which will be the same variable that gets remapped in the global scope. additionally, lang.getObject is aware of the remapping so lang.getObject('dojox.rpc', true); will add the rpc property to the globally remapped "dojox" global.

basically, you can't rely on any global references.

comment:7 Changed 7 years ago by haysmark

Resolution: fixed
Status: reopenedclosed

In [29120]:

Use lang.getObject instead of hardcoding the dojox global. Thanks neonstalwart. Fixes #15289.

comment:8 Changed 7 years ago by haysmark

Version: 1.7.21.6.0

This was actually a regression from 1.6->1.7.

comment:9 Changed 7 years ago by haysmark

In [29142]:

Fix regression from 1.6 that introduced an undefined global, which prevented synchronous saving. Refs #15289.

Note: See TracTickets for help on using tickets.