From 109add76520e7c2dbd2530700f91d3d7e5797e23 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Fri, 21 Feb 2020 16:08:36 -0500 Subject: [PATCH] LP1864056: Don't compare multiple new Date()s This branch addresses a race condition when checking out or renewing items. (The use of minDate in items_out was implicitly immune to this issue, but that is made explicit with this patch.) To test ------- [1] The race condition would be difficult to reliably reproduce directly, although a tool like https://github.com/mattzeunert/javascript-clock-speedup might help simulate the problem, so to test, verify that the following actions do not break: * checking out a loan, both with and without setting a specific due date * renewing a loan with a specific due date from the patron items out tab * renewing a loan from Circulation -> Renew Items, both with and without setting a specific due date. Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton Signed-off-by: Jane Sandberg --- Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js | 5 +++-- Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js | 5 +++-- Open-ILS/web/js/ui/default/staff/circ/renew/app.js | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index 95105465bf..df4945bfbb 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -9,6 +9,7 @@ angular.module('egPatronApp').controller('PatronCheckoutCtrl', function($scope , $q , $routeParams , egCore , egUser , patronSvc , egGridDataProvider , $location , $timeout , egCirc , ngToast) { + var now = new Date(); $scope.initTab('checkout', $routeParams.id).finally(function(){ $scope.focusMe = true; @@ -16,10 +17,10 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , $scope.checkouts = patronSvc.checkouts; $scope.checkoutArgs = { noncat_type : 'barcode', - due_date : new Date() + due_date : new Date(now) }; - $scope.minDate = new Date(); + $scope.minDate = new Date(now); $scope.outOfRange = false; $scope.gridDataProvider = egGridDataProvider.instance({ get : function(offset, count) { diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js index 26341c1844..b17702f889 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js @@ -503,11 +503,12 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc , controller : [ '$scope','$uibModalInstance', function($scope , $uibModalInstance) { + var now = new Date(); $scope.outOfRange = false; - $scope.minDate = new Date(); + $scope.minDate = new Date(now); $scope.args = { barcodes : barcodes, - date : new Date() + date : new Date(now) } $scope.cancel = function() {$uibModalInstance.dismiss()} diff --git a/Open-ILS/web/js/ui/default/staff/circ/renew/app.js b/Open-ILS/web/js/ui/default/staff/circ/renew/app.js index b5cdfd194b..95f59ebd2c 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/renew/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/renew/app.js @@ -32,16 +32,16 @@ angular.module('egRenewApp', .controller('RenewCtrl', ['$scope','$window','$location','egCore','egGridDataProvider','egCirc', function($scope , $window , $location , egCore , egGridDataProvider , egCirc) { + var now = new Date(); egCore.hatch.getItem('circ.renew.strict_barcode') .then(function(sb){ $scope.strict_barcode = sb }); $scope.focusBarcode = true; $scope.outOfRange = false; - $scope.minDate = new Date(); + $scope.minDate = new Date(now); $scope.renewals = []; - var today = new Date(); - $scope.renewalArgs = {due_date : today}; + $scope.renewalArgs = {due_date : new Date(now)}; $scope.sort_money = function (a,b) { var ma = parseFloat(a); -- 2.11.0