Bugzilla – Attachment 190907 Details for
Bug 41520
Using additional fields on ERM agreements results in an error when loading the agreements table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41520: Filter out record_table from AdditionalFieldValue API responses
Bug-41520-Filter-out-recordtable-from-AdditionalFi.patch (text/plain), 2.19 KB, created by
Jan Kissig
on 2026-01-05 18:47:05 UTC
(
hide
)
Description:
Bug 41520: Filter out record_table from AdditionalFieldValue API responses
Filename:
MIME Type:
Creator:
Jan Kissig
Created:
2026-01-05 18:47:05 UTC
Size:
2.19 KB
patch
obsolete
>From ab5beb665610b408ef14805d7dcab07192d2bf42 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 5 Jan 2026 15:03:30 +0000 >Subject: [PATCH] Bug 41520: Filter out record_table from AdditionalFieldValue > API responses > >Bug 35451 added a record_table field to the additional_field_values >database table for performance optimization (better joins). However, >this field was not added to the OpenAPI schema, and with >additionalProperties: false, the API validator rejects responses >containing it. > >Rather than adding this internal implementation detail to the public >API schema, this patch adds a custom to_api method to >Koha::AdditionalFieldValue that filters out the record_table field. > >This approach: >1. Keeps the database optimization from Bug 35451 >2. Prevents internal implementation details from cluttering the API >3. Maintains context that API consumers already have from parent objects >4. Fixes OpenAPI validation errors for ERM agreements, licenses, and > packages using extended_attributes > >Test plan: >1. Create an ERM agreement with additional fields/extended attributes >2. Access the agreement via the API with extended_attributes embedded >3. Verify the response includes extended_attributes but not record_table >4. Confirm no OpenAPI validation warnings in plack-api-error.log >5. prove t/db_dependent/api/v1/erm_agreements.t >6. Verify all tests pass > >Signed-off-by: Jan Kissig <bibliothek@th-wildau.de> >--- > Koha/AdditionalFieldValue.pm | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > >diff --git a/Koha/AdditionalFieldValue.pm b/Koha/AdditionalFieldValue.pm >index c8dfd7a1bda..b0870493787 100644 >--- a/Koha/AdditionalFieldValue.pm >+++ b/Koha/AdditionalFieldValue.pm >@@ -28,6 +28,23 @@ sub field { > return Koha::AdditionalField->_new_from_dbic( $self->_result()->field() ); > } > >+=head3 to_api >+ >+Overloaded to_api method to exclude internal fields from API representation >+ >+=cut >+ >+sub to_api { >+ my ( $self, $params ) = @_; >+ >+ my $json = $self->SUPER::to_api($params); >+ >+ # Remove internal database optimization fields that shouldn't be exposed via API >+ delete $json->{record_table}; >+ >+ return $json; >+} >+ > =head2 Internal methods > > =head3 _type >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41520
:
190892
|
190893
|
190906
|
190907
|
190915
|
190916
|
190927
|
190928