Summary: | 'Batch modify' button on itemnumber causes internal server error if itemnumbers do not correspond to real items. | ||
---|---|---|---|
Product: | Koha | Reporter: | Barton Chittenden <barton> |
Component: | Reports | Assignee: | Bugs List <koha-bugs> |
Status: | CLOSED WORKSFORME | QA Contact: | Testopia <testopia> |
Severity: | minor | ||
Priority: | P5 - low | CC: | jonathan.druart, margaret |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: |
Note that even though the query that I used to illustrate this problem won't ever occur in production, this was triggered by a real report, that looked something like this: SELECT aqbasket.basketname, aqbasket.closedate, aqorders.biblionumber, aqorders_items.itemnumber, items.itemnumber AS 'items.itemnumber', biblio.title, items.barcode FROM aqbasket LEFT JOIN aqorders USING (basketno) LEFT JOIN aqorders_items on (aqorders.ordernumber = aqorders_items.ordernumber) LEFT JOIN biblio on (aqorders.biblionumber = biblio.biblionumber) LEFT JOIN items on (aqorders_items.itemnumber = items.itemnumber) WHERE aqbasket.basketname='XXXXXXXXXXXXXX' GROUP BY aqorders_items.itemnumber The 'Batch Modify' button was attached to the 'aqorders_items.itemnumber' column, and there were instances where that was populated, even when 'items.itemnumber' was NULL. Can you give us a step by step plan to recreate the problem please? I have try to use the SQL query from comment 1: - Create an order with 3 items - Receive - Remove an item - Execute the report => I see the 3 lines with an itemnumber that have been deleted (ie. do not longer exist in the items table). - Batch operation, delete items => I see 2 items to delete |
To re-create: Create a new report from SQL using the following query: select title, itemnumber + 1 as itemnumber from biblio inner join items using (biblionumber) order by itemnumber desc LIMIT 1 The value in the itemnumber column will *not* correspond to any item in the items table. Run the report and click the 'Batch modify' button. This causes an internal server error with the following error message: Can't call method "title" on an undefined value at /usr/share/koha/intranet/cgi-bin/tools/batchMod.pl line 583. The problem is that 'my $biblio = Koha::Biblios->find( $itemdata->{biblionumber}' at line 577 *can't* be guaranteed to return a valid biblio record, so we *must* check whether it's defined before we access its members. 575 # grab title, author, and ISBN to identify bib that the item 576 # belongs to in the display 577 my $biblio = Koha::Biblios->find( $itemdata->{biblionumber} ); >>578 $this_row{title} = $biblio->title; 579 $this_row{author} = $biblio->author; 580 $this_row{isbn} = $biblio->biblioitem->isbn; 581 $this_row{biblionumber} = $biblio->biblionumber;