"session" not set for memory store #61

Closed
jvpoucke opened this Issue Nov 11, 2011 · 1 comment

Projects

None yet

2 participants

@jvpoucke

Code in persistence.store.memory.js should be:
persistence.flush = function (tx, callback) {
var args = argspec.getArgs(arguments, [
{ name: "tx", optional: true, check: persistence.isTransaction },
{ name: "callback", optional: true, check: argspec.isCallback(), defaultValue: function(){} }
]);

var session = this; /*<------ bugfix ---*/
var fns = persistence.flushHooks;
persistence.asyncForEach(fns, function(fn, callback) {
    fn(session, tx, callback); /*<------ else session in undefined here ---*/
  }, function() {
    var trackedObjects = persistence.trackedObjects;
    for(var id in trackedObjects) {
      if(trackedObjects.hasOwnProperty(id)) {
        if (persistence.objectsToRemove.hasOwnProperty(id)) {
          delete trackedObjects[id];
        } else {
          trackedObjects[id]._dirtyProperties = {};
        }
      }
    }
    args.callback();
  });

};

@zefhemel
Collaborator

Fixed. Thanks!

@zefhemel zefhemel closed this Nov 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment