From 258d9fad0f8bad08f17eb6877e2e7b064e50f326 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sat, 14 Jan 2017 20:15:35 -0800 Subject: [PATCH] Never fulfill requests that are on hold. Requests on hold can never be fulfilled. If you want to fulfill a request that is currently on hold, the right semantic is that you should remove the hold, then fulfill the request. Note that this test now passes and it didn't before: fulfillRequest: .... but undef is returned when attempting to fulfill a held request. --- Supporters/lib/Supporters.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 9f9fce5..c117f11 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -1289,6 +1289,16 @@ sub fulfillRequest($$) { my $fulfillRecord = $self->dbh()->selectall_hashref($fulfillLookupSql, "request_id"); if (not defined $fulfillRecord or not defined $fulfillRecord->{$requestId}) { + # First check if request is held. If it's held, it cannot be fulfilled. + my $holdReq = $self->dbh()->selectall_hashref("SELECT id, request_id, release_date " . + "FROM request_hold WHERE request_id = " . + $self->dbh->quote($requestId, 'SQL_INTEGER'), + 'request_id'); + return undef + if (defined $holdReq and defined $holdReq->{$requestId} and defined $holdReq->{$requestId}{id} + and $TODAY lt $holdReq->{$requestId}{release_date}); + + # Ok, it's not on hold, so go ahead and fulfill it. $self->_beginWork; my $sth = $self->dbh->prepare("INSERT INTO fulfillment(request_id, who, how, date) " . "VALUES(? , ? , ? , date('now'))");