Bug 14001 - Inventory has bad $_ references
Summary: Inventory has bad $_ references
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Mark Tompsett
QA Contact: Testopia
URL:
Keywords:
: 12329 (view as bug list)
Depends on: 7684
Blocks: 16834
  Show dependency treegraph
 
Reported: 2015-04-15 16:38 UTC by Mark Tompsett
Modified: 2017-06-14 22:10 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 14001 - Inventory tool is not plack friendly (994 bytes, patch)
2015-04-15 16:45 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14001 - Inventory tool is not plack friendly (2.03 KB, patch)
2015-04-15 21:02 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14001: [DO NOT PUSH TO MASTER] Proof that the $_ is wrong. (5.45 KB, patch)
2015-05-28 16:21 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14001 - Inventory has bad $_ references (2.16 KB, patch)
2015-05-28 16:27 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14001 - Inventory has bad $_ references (2.20 KB, patch)
2015-05-28 16:29 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 14001: [DO NOT PUSH TO MASTER] Proof that the $_ is wrong. (5.57 KB, patch)
2015-06-14 06:07 UTC, Indranil Das Gupta
Details | Diff | Splinter Review
Bug 14001 - Inventory has bad $_ references (2.34 KB, patch)
2015-06-14 06:14 UTC, Indranil Das Gupta
Details | Diff | Splinter Review
Bug 14001 - Inventory has bad $_ references (2.41 KB, patch)
2015-06-16 08:50 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Tompsett 2015-04-15 16:38:38 UTC
Wanting to profile tools/inventory.pl, the following steps were take:
- installed the kohadevbox (https://github.com/digibib/kohadevbox)
- Log in to plack staff client
- Add one book via z39.50, setting barcode to a known value (BARCODE1)
- Wait for the reindex
- Home -> Tools -> Inventory/Stocktaking
- Browse for a file with the barcode in it
- Click 'Submit'
- Acknowledge it will take long
- *kaboom*
Plack barfed on line 297.
Comment 1 Mark Tompsett 2015-04-15 16:45:49 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2015-04-15 21:02:28 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-04-29 10:08:12 UTC
Mark,
I don't manage to recreate the error.
I would say the patch is correct, but there is certainly another issue, even without Plack: the $_ (l. ~297) equals {} and does not contain the item data.
It would be good to highlight this problem in the test plan.
Comment 4 Mark Tompsett 2015-05-28 16:21:25 UTC Comment hidden (obsolete)
Comment 5 Mark Tompsett 2015-05-28 16:27:27 UTC Comment hidden (obsolete)
Comment 6 Mark Tompsett 2015-05-28 16:29:09 UTC Comment hidden (obsolete)
Comment 7 Indranil Das Gupta 2015-06-14 06:07:22 UTC
Created attachment 40117 [details] [review]
Bug 14001: [DO NOT PUSH TO MASTER] Proof that the $_ is wrong.

TEST PLAN
---------
 1) create new branch based on master
 2) apply this patch
 3) make sure you have the barcode of something in your inventory.
    or add it accordingly.
 4) Create a dummy barcode file with that barcode.
 5) Home -> Tools -> Inventory/stocktaking
 6) Browse for that file
 7) Click the 'Compare barcodes list to results:' checkbox.
 8) Click the 'Submit' button.
 9) Check the koha error log.
    -- Errors being looked for are like:
[Thu May 28 12:14:53.454702 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: [Thu May 28 12:14:53 2015] inventory.pl: Use of uninitialized value in concatenation (.) or string at /home/mtompset/kohaclone/tools/inventory.pl line 278, <$fh> line 1., referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.454737 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $_    VERSION: , referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.454757 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $item VERSION: 2015-05-28, referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455013 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: [Thu May 28 12:14:53 2015] inventory.pl: Use of uninitialized value in concatenation (.) or string at /home/mtompset/kohaclone/tools/inventory.pl line 278, <$fh> line 1., referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455033 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $_    VERSION: , referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455052 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $item VERSION: 2015-05-25, referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455345 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: [Thu May 28 12:14:53 2015] inventory.pl: Use of uninitialized value in concatenation (.) or string at /home/mtompset/kohaclone/tools/inventory.pl line 278, <$fh> line 1., referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455366 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $_    VERSION: , referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455384 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $item VERSION: 2015-05-25, referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455539 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: [Thu May 28 12:14:53 2015] inventory.pl: Use of uninitialized value in concatenation (.) or string at /home/mtompset/kohaclone/tools/inventory.pl line 278, <$fh> line 1., referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455539 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $_    VERSION: , referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.455540 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $item VERSION: 2015-05-25, referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.458994 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: [Thu May 28 12:14:53 2015] inventory.pl: Use of uninitialized value in concatenation (.) or string at /home/mtompset/kohaclone/tools/inventory.pl line 325, <$fh> line 1., referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.459018 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $_    VERSION (MOD): , referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl
[Thu May 28 12:14:53.459037 2015] [cgi:error] [pid 2428] [client 192.168.45.37:52408] AH01215: $item VERSION (MOD): 2, referer: http://library-admin.debiankoha.ca/cgi-bin/koha/tools/inventory.pl

As this should not be pushed to master, and is merely provided as evidence that there is a problem.
Confirm that the two places correspond to the VERSION and VERSION (MOD) message locations.

The test patch proves the error condition

Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com>
Comment 8 Indranil Das Gupta 2015-06-14 06:14:14 UTC Comment hidden (obsolete)
Comment 9 Jonathan Druart 2015-06-16 08:43:42 UTC
Introduced by bug 7684
Comment 10 Jonathan Druart 2015-06-16 08:50:28 UTC
Created attachment 40164 [details] [review]
Bug 14001 - Inventory has bad $_ references

After receiving an error while attempt a simple inventory run,
Two lines were changed from:
    ...$_->...
to
    ...$item->...
since the loop variable is $item. And $_ is not set to the
expected hash reference, when there is a loop variable.

This also helps explain the "Why are there blank dates on my
last seen field?" problem that has been mentioned by users.

TEST PLAN
---------
 1) Apply this patch after a reset to master.
 2) Log in to staff client
 3) Add one item via z39.50, setting barcode to a known value (BARCODE1)
 4) Wait for the reindex
 5) Home -> Tools -> Inventory/Stocktaking
 6) Browse for a file with the barcode in it
 7) Set the library dropdown to the library branch of the added item.
 8) Check 'Compare barcodes list to results:'
 9) Click 'Submit'
    -- This should not die under plack.
       This should not generate blank last seen dates.
       The last seen dates should be as expected.
10) run koha qa test tools
11) Confirm the two change point correspond to the two change points
    in the patch which shall not be pushed to master.

The test result comply with expected outcome outlined in test plan.

Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 11 Jonathan Druart 2015-06-16 08:51:06 UTC
This fix should be backported to all supported versions (>=3.14)
Comment 12 Tomás Cohen Arazi 2015-06-22 14:54:38 UTC
Patch pushed to master.

Thanks Mark!
Comment 13 Mark Tompsett 2015-07-08 15:39:33 UTC
As per Jonathan's comment #11, I confirmed the fix cleanly applies back to 3.14.x, and added candidate keywords. :)
Comment 14 Chris Cormack 2015-07-08 21:05:08 UTC
Pushed to 3.20.x will be in 3.20.2
Comment 15 Jonathan Druart 2015-07-14 14:10:18 UTC
*** Bug 12329 has been marked as a duplicate of this bug. ***
Comment 16 Mason James 2015-07-25 12:58:01 UTC
Pushed to 3.16.x, will be in 3.16.13