Bugzilla – Attachment 187526 Details for
Bug 40777
500 Error: Something went wrong when loading the table Should Exit Cleanly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40777: Introduce Koha::Database::DataInconsistency
Bug-40777-Introduce-KohaDatabaseDataInconsistency.patch (text/plain), 3.62 KB, created by
Jonathan Druart
on 2025-10-07 14:18:18 UTC
(
hide
)
Description:
Bug 40777: Introduce Koha::Database::DataInconsistency
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-10-07 14:18:18 UTC
Size:
3.62 KB
patch
obsolete
>From 6e12cba512043ed779ec2433a8c4d01a0fc0b678 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 7 Oct 2025 16:10:51 +0200 >Subject: [PATCH] Bug 40777: Introduce Koha::Database::DataInconsistency > >--- > Koha/Database/DataInconsistency.pm | 42 +++++++++++++++++++ > .../search_for_data_inconsistencies.pl | 21 ++++------ > 2 files changed, 50 insertions(+), 13 deletions(-) > create mode 100644 Koha/Database/DataInconsistency.pm > >diff --git a/Koha/Database/DataInconsistency.pm b/Koha/Database/DataInconsistency.pm >new file mode 100644 >index 00000000000..9f67e48f1b4 >--- /dev/null >+++ b/Koha/Database/DataInconsistency.pm >@@ -0,0 +1,42 @@ >+package Koha::Database::DataInconsistency; >+ >+use Modern::Perl; >+use Koha::I18N qw( __x ); >+ >+sub item_library { >+ my ( $self, $items ) = @_; >+ >+ $items = $items->search( { -or => { homebranch => undef, holdingbranch => undef } } ); >+ my @errors; >+ while ( my $item = $items->next ) { >+ if ( not $item->homebranch and not $item->holdingbranch ) { >+ push @errors, >+ __x( >+ "Item with itemnumber={itemnumber} does not have homebranch and holdingbranch defined", >+ itemnumber => $item->itemnumber >+ ); >+ } elsif ( not $item->homebranch ) { >+ push @errors, >+ __x( >+ "Item with itemnumber={itemnumber} does not have homebranch defined", >+ itemnumber => $item->itemnumber >+ ); >+ } else { >+ push @errors, >+ __x( >+ "Item with itemnumber={itemnumber} does not have holdingbranch defined", >+ itemnumber => $item->itemnumber >+ ); >+ } >+ } >+ return @errors; >+} >+ >+sub for_biblio { >+ my ( $self, $biblio ) = @_; >+ my @errors; >+ push @errors, $self->item_library( $biblio->items ); >+ return @errors; >+} >+ >+1; >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index 66f949ad6a8..37be69475c9 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -27,23 +27,18 @@ use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; > use C4::Biblio qw( GetMarcFromKohaField ); >+use Koha::Database::DataInconsistency; > > { >- my $items = Koha::Items->search( { -or => { homebranch => undef, holdingbranch => undef } } ); >- if ( $items->count ) { new_section("Not defined items.homebranch and/or items.holdingbranch") } >- while ( my $item = $items->next ) { >- if ( not $item->homebranch and not $item->holdingbranch ) { >- new_item( >- sprintf "Item with itemnumber=%s does not have homebranch and holdingbranch defined", >- $item->itemnumber >- ); >- } elsif ( not $item->homebranch ) { >- new_item( sprintf "Item with itemnumber=%s does not have homebranch defined", $item->itemnumber ); >- } else { >- new_item( sprintf "Item with itemnumber=%s does not have holdingbranch defined", $item->itemnumber ); >+ my $items = Koha::Items->search; >+ my @errors = Koha::Database::DataInconsistency->item_library($items); >+ if (@errors) { >+ new_section("Not defined items.homebranch and/or items.holdingbranch"); >+ for my $error (@errors) { >+ new_item($error); > } > } >- if ( $items->count ) { new_hint("Edit these items and set valid homebranch and/or holdingbranch") } >+ if (@errors) { new_hint("Edit these items and set valid homebranch and/or holdingbranch") } > } > > { >-- >2.34.1
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 40777
: 187526 |
187527
|
187528