Bugzilla – Attachment 191603 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), 6.84 KB, created by
Victor Grousset/tuxayo
on 2026-01-18 14:44:04 UTC
(
hide
)
Description:
Bug 40777: Introduce Koha::Database::DataInconsistency
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2026-01-18 14:44:04 UTC
Size:
6.84 KB
patch
obsolete
>From bdc14d1e2e92417cbf2a97f0b2fc30b8d4849b8b 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 >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >test plan: >1. Export a record with an item from the staff interface as MARCXML (Save > MARCXML). >2. Edit the file and remove the 952$a (home library) and 952$b (current library). >3. Delete the item and record in the staff interface. >4. Import the exported record and item from the MARCXML file: > - Cataloging > Import > Stage for import > . Settings > Format: MARCXML > - Stage for import > - View batch link on the job details page (assuming successfully staged) > . New record framework: change to Books, Booklets, Workbooks >5. Turn on the browser developer tools and view the console. >6. Access the details page for the new record. >7. Note that you get: > - A "Processing" dialog box on screen > - A browser pop-up window/dialog box with: > Something went wrong when loading the table. > 500: Internal server error > - Click OK > - The console shows: > . Failed to load resource: the server responded with a status of 500 (Internal Server Error) > . Got 500 (Internal Server Error) > . DataTables warning: table id=holdings_table - Ajax error. For more information about this error, please see https://datatables.net/tn/7 >8. Run misc/maintenance/search_for_data_inconsistencies.pl, you get these result (the itemnumber may be different): > == Not defined items.homebranch and/or items.holdingbranch == > * Item with itemnumber=973 does not have home and holding library defined > => Edit these items and set valid homebranch and/or holdingbranch > (ΓΆΓΆ don't do it, it's part of the message content) >9. Apply the patch. >10. Restart everything. >11. Refresh the details screen for the imported record. >12. You now get the same as step 7, but with added "Have a look at the "Audit" button in the toolbar" text in the browser pop-up dialog box: > - A "Processing" dialog box on screen > - A browser pop-up window/dialog box with: > Something went wrong when loading the table. > 500: Internal server error > Have a look at the "Audit" button in the toolbar > - Click OK > - The console shows: > . GET http[URL for the record....] 500 (Internal Server Error) > . Got 500 (Internal Server Error) > . DataTables warning: table id=holdings_table - Ajax error. For more information about this error, please see https://datatables.net/tn/7 >13. Click on the Audit button. >14. You get a yellow box at the top of the record with: > Errors found > Item with itemnumber=973 does not have home and holding library defined > (Note that there is still the "Processing" dialog box, you can edit the item by select the "Items" option in the sidebar menu and then edit the item details - the home and current library files will be auto-populated with the current library, Centerville with KTD) >15. Repeat step 8, you get the same results. >16. The tests pass: prove t/db_dependent/Koha/Database/DataInconsistency.t >17. Check the details page for another record that doesn't have any data issues - note the 'Audit' toolbar item, and if clicked should show a blue box at the top of the record with "No data inconsistency found." > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > 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 0000000000..9f67e48f1b >--- /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 66f949ad6a..37be69475c 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.52.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 40777
:
187526
|
187527
|
187528
|
188222
|
188223
|
188224
|
188225
|
188226
|
188227
|
189598
|
190261
|
190262
|
190263
|
190264
|
190265
|
190266
|
190267
|
190268
|
190269
|
190270
|
190884
|
190885
| 191603 |
191604
|
191605
|
191606
|
191607
|
191608
|
191609
|
191610
|
191611
|
191612
|
191613
|
191614
|
191615