From 18ef1cef2adb0beffe1758690bc8afc8e1189917 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 9 Oct 2014 17:32:42 -0400 Subject: [PATCH] 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 Signed-off-by: Ben Shum --- Open-ILS/web/js/dojo/openils/PermaCrud.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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; -- 2.43.2