Bugzilla – Attachment 193992 Details for
Bug 35104
We should warn when attempting to save MARC records that contain characters invalid in XML
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35104: Update Biblio.t to reflect graceful non-XML stripping behaviour
56ff5d0.patch (text/plain), 3.30 KB, created by
Martin Renvoize (ashimema)
on 2026-02-26 13:43:54 UTC
(
hide
)
Description:
Bug 35104: Update Biblio.t to reflect graceful non-XML stripping behaviour
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-26 13:43:54 UTC
Size:
3.30 KB
patch
obsolete
>From 56ff5d0a37af5663c0262d4ef7bfb22bfb34592c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 26 Feb 2026 13:43:21 +0000 >Subject: [PATCH] Bug 35104: Update Biblio.t to reflect graceful non-XML > stripping behaviour > >The ModBiblio subtest was written for the old exception-throwing behaviour >where invalid MARC would emit a Perl warn() and the error would appear in >the action log. With the graceful stripping introduced by this bug: > >- StripNonXmlChars recovers the record silently (no Perl warn()) >- The stripping event is reported via the warnings arrayref in $options >- nonxml_stripped is persisted on biblio_metadata >- ModBiblio still succeeds and logs the modification to action logs > >Update the three assertions accordingly. >--- > t/db_dependent/Biblio.t | 31 +++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index bca89014a23..2107fba2d02 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -1204,29 +1204,36 @@ subtest 'GetFrameworkCode' => sub { > > }; > >-subtest 'ModBiblio on invalid record' => sub { >+subtest 'ModBiblio on record with strippable non-XML characters' => sub { > plan tests => 3; > > t::lib::Mocks::mock_preference( "CataloguingLog", 1 ); > >- # We create a record with an onvalid control character in the MARC >+ # We create a record with an invalid control character (chr(31)) in the MARC > my $record = MARC::Record->new(); >- my $field = MARC::Field->new( '650', '', '', 'a' => '00aD000015937' ); >+ my $field = MARC::Field->new( '650', '', '', 'a' => '00' . chr(31) . 'aD000015937' ); > $record->append_fields($field); > > my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' ); > >- warning_like { C4::Biblio::ModBiblio( $record, $biblionumber, '' ); } >- qr/parser error : PCDATA invalid Char value 31/, >- 'Modding the biblio warns about the encoding issues'; >- my $action_logs = >- Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } ); >- is( $action_logs->count, 1, "Modification of biblio was successful and recorded" ); >- my $action_log = $action_logs->next; >+ # New behaviour: strippable non-XML characters are silently fixed; the >+ # stripping event is reported via the warnings arrayref, not Perl warn() >+ my @warnings; >+ C4::Biblio::ModBiblio( $record, $biblionumber, '', { warnings => \@warnings } ); >+ like( >+ $warnings[0]{message}, qr/parser error : PCDATA invalid Char value 31/, >+ 'Non-XML character stripping reported via warnings arrayref' >+ ); >+ >+ my $metadata = Koha::Biblios->find($biblionumber)->metadata; > like( >- $action_log->info, qr/parser error : PCDATA invalid Char value 31/, >- "Metadata issue successfully logged in action logs" >+ $metadata->nonxml_stripped, qr/parser error : PCDATA invalid Char value 31/, >+ 'nonxml_stripped persisted on biblio_metadata after ModBiblio' > ); >+ >+ my $action_logs = >+ Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } ); >+ is( $action_logs->count, 1, "Modification of biblio was successfully recorded in action logs" ); > }; > > subtest 'UpdateTotalIssues on Invalid record' => sub { >-- >2.53.0 >
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 35104
:
157625
|
157627
|
157628
|
157642
|
159615
|
159620
|
159621
|
159630
|
159810
|
159811
|
159812
|
159813
|
166431
|
173145
|
173146
|
176820
|
176821
|
176850
|
176851
|
176852
|
176860
|
193985
|
193986
|
193987
|
193988
|
193989
|
193990
|
193991
|
193992
|
193993
|
193994
|
193995
|
193996
|
193997
|
193998
|
193999
|
194000
|
194001
|
194004
|
194005
|
194006
|
194007
|
194008
|
194009
|
194010
|
194011
|
194012
|
194013