From: Dan Wells Date: Thu, 9 Oct 2014 21:32:42 +0000 (-0400) Subject: LP#1379824 Make PermaCrud.js disconnect() actually disconnect X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fysuarez%2Flp1379824_fix_pcrud_disconnects_signoff;p=working%2FEvergreen.git LP#1379824 Make PermaCrud.js disconnect() actually disconnect The disconnect() method in PermaCrud.js was meant to wrap the underlying session disconnect, but it never actually disconnected the session. This could lead to problems in long-living PermaCrud objects, as they may think they are still connected when they are not (the session remote_id is never cleared). Also, remove a couple (now redundant) manual session.disconnect() calls. Signed-off-by: Dan Wells Signed-off-by: Yamil Suarez --- diff --git a/Open-ILS/web/js/dojo/openils/PermaCrud.js b/Open-ILS/web/js/dojo/openils/PermaCrud.js index c284c65fb1..2df2fa1e7c 100644 --- a/Open-ILS/web/js/dojo/openils/PermaCrud.js +++ b/Open-ILS/web/js/dojo/openils/PermaCrud.js @@ -60,13 +60,11 @@ if(!dojo._hasResource["openils.PermaCrud"]) { }, disconnect : function ( onerror ) { + // session.disconnect() does not return any indication of success, + // so we must simply assume it worked + this.session.disconnect(); this.connected = false; return true; - // disconnect returns nothing, which is null, which is not true, cause the following to always run ... arg. - if (!this.session.disconnect()) { - if (onerror) onerror(this.session); - return false; - } }, _session_request : function ( args /* hash */, commitOnComplete /* set to true, else no */ ) { @@ -82,7 +80,6 @@ if(!dojo._hasResource["openils.PermaCrud"]) { if (args.timeout && !args.oncomplete && !args.onresponse) { // pure sync call args.oncomplete = function (r) { me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth()); - me.session.disconnect(); me.disconnect(); }; } else if (args.oncomplete) { // there's an oncomplete, fire that, and then end the transaction @@ -93,7 +90,6 @@ if(!dojo._hasResource["openils.PermaCrud"]) { ret = orig_oncomplete(r); } finally { me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth()); - me.session.disconnect(); me.disconnect(); } return ret;