From 3a2e0f1ef874a58b848638276927d456678d55ee Mon Sep 17 00:00:00 2001 From: Ayoub Glizi-Vicioso Date: Fri, 13 Feb 2026 15:24:56 -0500 Subject: [PATCH] Bug 38122: Fix server error when handling malformed request parameters --- Koha/REST/V1/Biblios.pm | 4 ++-- api/v1/swagger/paths/biblios.yaml | 6 +----- api/v1/swagger/swagger.yaml | 6 ++++++ .../includes/html_helpers/tables/items/catalogue_detail.inc | 4 ++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 89d0629cdd..4ffca7dbfb 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -255,7 +255,7 @@ sub get_items { # Deletion of parameter to avoid filtering on the items table in the case of bookings on 'itemtype' $c->req->params->remove('bookable'); - my $group_by_status = $c->param('group_by_status'); + my $group_by_status = $c->param('group_by_status') ? 1 : 0; $c->req->params->remove('group_by_status'); return $c->render_resource_not_found("Bibliographic record") @@ -274,7 +274,7 @@ sub get_items { $items_rs = $items_rs->search( {}, { - order_by => [ + order_by => [ \[ "CASE WHEN (withdrawn != 0) THEN '10_Withdrawn' WHEN (itemlost != 0) THEN '09_Lost' diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index 74e79fac64..81129e5c64 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -494,16 +494,12 @@ - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - $ref: "../swagger.yaml#/parameters/request_id_header" + - $ref: "../swagger.yaml#/parameters/group_by_status" - name: bookable in: query description: Limit to items that are bookable required: false type: boolean - - name: group_by_status - in: query - description: Return the items grouped by status - required: false - type: boolean consumes: - application/json produces: diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 9a9b7af756..78206d137c 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -933,6 +933,12 @@ parameters: name: _per_page required: false type: integer + group_by_status: + name: group_by_status + in: query + description: "Return the items grouped by status" + required: false + type: boolean preservation_processing_id_pp: description: processing internal identifier in: path diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 908165866a..00c480c023 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -381,6 +381,7 @@ }; if (is_grouping) { + dt_options["ordering"]= false; dt_options["rowGroup"] = { "dataSrc": function(row) { return get_display_status(row, true); @@ -633,6 +634,9 @@ searchable: false, orderable: false, render: function (data, type, row, meta) { + if (type === 'sort' || type === 'filter' || type === 'type') { + return get_display_status(row, true); + } let nodes = ""; row._status.forEach( status => { if ( status == 'checked_out' || status == 'local_use') { -- 2.52.0