Bug 9281 - Impossible to create an order from a staged file
Summary: Impossible to create an order from a staged file
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-13 13:16 UTC by Jonathan Druart
Modified: 2014-05-26 21:05 UTC (History)
3 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 9281: FIX add an order from a staged file (1.33 KB, patch)
2012-12-13 13:19 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 9281: FIX add an order from a staged file (1.39 KB, patch)
2012-12-14 16:25 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 9284 - JavaScript should follow rules recommended by JSHint (9.46 KB, patch)
2012-12-14 16:44 UTC, Owen Leonard
Details | Diff | Splinter Review
test file (113 bytes, application/x-perl)
2013-01-22 09:28 UTC, Jonathan Druart
Details
[SIGNED-OFF] Bug 9281: FIX add an order from a staged file (1.79 KB, patch)
2013-01-23 07:34 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2012-12-13 13:16:24 UTC
When you try to create an order from a staged file, you get a sql error:

 DBD::mysql::st execute failed: called with 2 bind variables when 1 are needed at /home/koha/src/C4/Members.pm line 559
Comment 1 Jonathan Druart 2012-12-13 13:19:51 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2012-12-14 16:25:00 UTC Comment hidden (obsolete)
Comment 3 Owen Leonard 2012-12-14 16:44:59 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2012-12-14 16:45:38 UTC
Comment on attachment 14143 [details] [review]
Bug 9284 - JavaScript should follow rules recommended by JSHint

Sorry, wrong bug number!
Comment 5 Katrin Fischer 2013-01-16 07:18:40 UTC
Hi Jonathan,

I am sorry, but I can't reproduce the problem described. 

I added 2 order lines from a file I had staged some time ago and no error appeared.

I also tried adding the rest of the staged file as batch and the orders were created perfectly.

The logs are clean too.

AcqCreateItem is set to 'on receive'.

What am I missing?
Comment 6 Jonathan Druart 2013-01-16 11:23:11 UTC
(In reply to comment #5)
> What am I missing?

Hi Katrin,
Yep I forgot 1 thing, on the "Add orders from" page, click on the "Save" button instead of the "Add order" link.
Comment 7 Katrin Fischer 2013-01-17 07:07:44 UTC
Hi Jonathan,

I just tried it again and I think I already did it yesterday:

>I also tried adding the rest of the staged file as batch and the orders were >created perfectly.

You mean the save button at the bottom of the page below the accounting details box? I successfully added all records from a staged file as orders that way - on error. Is there another condition that has to be met to trigger the error?
Comment 8 Jonathan Druart 2013-01-17 08:39:23 UTC
(In reply to comment #7)

> You mean the save button at the bottom of the page below the accounting
> details box?
Yes

> I successfully added all records from a staged file as orders
> that way - on error. Is there another condition that has to be met to
> trigger the error?

hum... strange.
Could you dump the hash in GetMember please?
(in C4/Members.pm l.530: warn Data::Dumper::Dumper \%information;)
I get:
  $VAR1 = {
    'C4::Members' => 'borrowernumber',
    '55' => undef, # 55 is $borrowernumber
  }
According to the code, you should enter in this routine for each biblio contained in your staged file.
Comment 9 Katrin Fischer 2013-01-20 22:18:51 UTC
Hi Jonathan, I am not sure I did it right, as my output looks quite different to yours. I added it at the beginning of the GetMembers routing, but the line number was totally different to the one you noted in your comment. Could you check?
Comment 10 Katrin Fischer 2013-01-20 22:25:52 UTC
[Sun Jan 20 23:24:55 2013] [error] [client 127.0.0.1] [Sun Jan 20 23:24:55 2013] basket.pl: $VAR1 = {, referer: http://localhost:8080/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=12&basketno=9&booksellerid=2
[Sun Jan 20 23:24:55 2013] [error] [client 127.0.0.1] [Sun Jan 20 23:24:55 2013] basket.pl:           'borrowernumber' => '1', referer: http://localhost:8080/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=12&basketno=9&booksellerid=2
[Sun Jan 20 23:24:55 2013] [error] [client 127.0.0.1] [Sun Jan 20 23:24:55 2013] basket.pl:         };, referer: http://localhost:8080/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=12&basketno=9&booksellerid=2
Comment 11 Jonathan Druart 2013-01-22 09:28:47 UTC
Created attachment 14738 [details]
test file

Hi Katrin,

Could you test this perl script on master please?

  perl test_bug9281.pl

gives me

  DBD::mysql::st execute failed: called with 2 bind variables when 1 are needed at /home/koha/src/C4/Members.pm line 560.
  Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/DBI.pm line 2054.
Comment 12 Katrin Fischer 2013-01-23 07:32:25 UTC
Hi Jonathan,

thank you for your patience. The file you provided gives me the error when running it and I finally found the error in my log files on ordering from a staged record:

[Wed Jan 23 08:25:51 2013] [error] [client 127.0.0.1] [Wed Jan 23 08:25:51 2013] addorderiso2709.pl: DBD::mysql::st execute failed: called with 2 bind variables when 1 are needed at /home/katrin/kohaclone/C4/Members.pm line 559., referer: http://localhost:8080/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=15&basketno=10&booksellerid=2

I still wonder, what kind of problem this will cause, as it seems that the acquisition module works correctly, with and without the patch. 

But there is nothing to say against the patch - passing QA :)
Comment 13 Katrin Fischer 2013-01-23 07:34:59 UTC
Created attachment 14767 [details] [review]
[SIGNED-OFF] Bug 9281: FIX add an order from a staged file

In GetMember the hash parameter contained
'C4::Members' => 'borrowernumber'
XXX => undef

Test plan:
In the acquition module, try to add an order to a basket from a staged file.
Without this patch, you get an error:
  DBD::mysql::st execute failed: called with 2 bind variables when 1 are needed at /home/koha/src/C4/Members.pm line 559

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests pass, error only appearing in the log file.

Test plan:
1) Create a basket
2) Add one or multiple order lines using a staged file and the 'batch' feature.
   This is done by using the "Save" button at the bottom of the page instead
   of the "Add order" link next to a single entry.
3) Check your koha-error_log for the error above.
Comment 14 Jared Camins-Esakov 2013-01-24 13:06:40 UTC
This patch has been pushed to master.
Comment 15 Chris Cormack 2013-02-01 08:31:15 UTC
Pushed to 3.10.x and 3.8.x will be in 3.10.3 and 3.8.10