]> git.evergreen-ils.org Git - Evergreen.git/commit
Fix a horrible regression when renewing multiple items at once in Items Out.
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 20 Aug 2009 08:01:42 +0000 (08:01 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 20 Aug 2009 08:01:42 +0000 (08:01 +0000)
commit4c10c2e8389f99c69af4a5688551e8121de9f54d
treedcc3b0fc4cedd3adda9b2990deaeb6b267e9c3a6
parent6430f6d03235b8590d9c3e428b076eea17ed12c3
Fix a horrible regression when renewing multiple items at once in Items Out.

Referencing loop variables in Javascript with closures is dangerous, so one strategy is to do something like this:

funcs = [];
for (var i = 0; i < my_array.length; i++ ) {

/* Bad */
// funcs.push( function(){ do_something( my_array[i] ); } );
/* Better */
funcs.push( function(safe_value){ return function(){ do_something( safe_value ); } }( my_array[i] ) );
}

In our case, our generated function accidentally referenced a value dependent on the loop variable instead of the corresponding argument of the function generator.

So we had multiple async renewal calls that depending on the timing, could try to renew the same item.  To further add insult to injury, this could potentially put the database in an inconsistent
state wtih duplicate circulations.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@13889 dcc99617-32d9-48b4-a31d-7c20da2025e4
Open-ILS/xul/staff_client/server/patron/items.js