From 6d8d80f1c12e214e54fbc542feb9701bac329ee2 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 10 Mar 2020 18:30:24 +0200
Subject: [PATCH] Treat missing or unknown dueStatus as normal in
 GetUserTransactions. (#1577)

---
 .../AjaxHandler/GetUserTransactions.php       | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/module/VuFind/src/VuFind/AjaxHandler/GetUserTransactions.php b/module/VuFind/src/VuFind/AjaxHandler/GetUserTransactions.php
index 6126c7409de..27e8eabe1a2 100644
--- a/module/VuFind/src/VuFind/AjaxHandler/GetUserTransactions.php
+++ b/module/VuFind/src/VuFind/AjaxHandler/GetUserTransactions.php
@@ -64,15 +64,16 @@ class GetUserTransactions extends AbstractIlsAndUserAction
             'overdue' => 0
         ];
         foreach ($items['records'] as $item) {
-            if (!isset($item['dueStatus'])) {
-                continue;
-            }
-            if ($item['dueStatus'] == 'overdue') {
-                $counts['overdue'] += 1;
-            } elseif ($item['dueStatus'] == 'due') {
-                $counts['warn'] += 1;
-            } else {
-                $counts['ok'] += 1;
+            switch ($item['dueStatus'] ?? '') {
+            case 'due':
+                $counts['warn']++;
+                break;
+            case 'overdue':
+                $counts['overdue']++;
+                break;
+            default:
+                $counts['ok']++;
+                break;
             }
         }
         return $this->formatResponse($counts);
-- 
GitLab