[Bug 12911] New: batch_id for new label batches can be assigned to several batches
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Bug ID: 12911 Summary: batch_id for new label batches can be assigned to several batches Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Tools Assignee: gmcharlt@gmail.com Reporter: nick@quecheelibrary.org QA Contact: testopia@bugs.koha-community.org When adding a new label batch the MAX batch_id is retrieved from creator_batches and incremented, however, the updated value is not saved until new items are added to the batch. This means that if one library opens a new batch but does not add items before another library opens the batch they will both be assigned the same batch number To recreate: 1 -In one browser window, go to tools->label creator and click the new batch button 2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button 3 - Note that both batches have the same number listed 4 - Add an item to the first batch - you should now see one item in the batch 5 - Add an item to the second batch, you should see two items in the batch I can also verify this happens pretty often in our shared system. C4:Creators 44 sub new { 45 my ($invocant) = shift; 46 my $type = ref($invocant) || $invocant; 47 my $self = { 48 batch_id => 0, 49 items => [], 50 branch_code => 'NB', 51 batch_stat => 0, # False if any data has changed and the db has not been updated 52 @_, 53 }; 54 my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM creator_batches;"); 55 $sth->execute(); 56 my $batch_id = $sth->fetchrow_array; 57 $self->{'batch_id'} = ++$batch_id unless $self->{'batch_id'} != 0; # this allows batch_id to be passed in for individual label printing 58 bless ($self, $type); 59 return $self; 60 } 61 62 sub add_item { 63 my $self = shift; 64 my $number = shift; 65 ref($self) =~ m/C4::(.+)::.+$/; 66 my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' : 'item_number'); 67 my $query = "INSERT INTO creator_batches (batch_id, $number_type, branch_code, creator) VALUES (?,?,?,?);"; 68 my $sth = C4::Context->dbh->prepare($query); 69 # $sth->{'TraceLevel'} = 3; 70 $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'}, $1); 71 if ($sth->err) { 72 warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr); 73 return -1; 74 } 75 $query = "SELECT max(label_id) FROM creator_batches WHERE batch_id=? AND $number_type=? AND branch_code=?;"; 76 my $sth1 = C4::Context->dbh->prepare($query); 77 $sth1->execute($self->{'batch_id'}, $number, $self->{'branch_code'}); 78 my $label_id = $sth1->fetchrow_array; 79 push (@{$self->{'items'}}, {$number_type => $number, label_id => $label_id}); 80 $self->{'batch_stat'} = 1; 81 return 0; 82 } -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@quecheelibrary.org -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shawn@pennmanor.net --- Comment #1 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- *** Bug 8042 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |Academy -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 --- Comment #2 from Thomas Wright <tomsStudy@gmail.com> --- Created attachment 35600 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=35600&action=edit Bug 12911 - batch_id for new label batches can be assigned to several batches -Added code to make a placeholder and thus reserve the batch number. -Added code to delete old placeholders everytime a new batch is made. -Modified code in SELECT query to disc Testing Plan -Open two koha staff windows in different browsers/inprivate. -On both navigate Home>Tools>Label Creator -Make a new batch in the first window -Make a new batch in the second window *The new batches created should have different batch numbers -Add items to one of the batches *Only the items added should show in the summary below. No placeholders should be shown -Go back to manage batches page on either window *The batch created which did not have any items added to it should not be displayed in this window -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Thomas Wright <tomsStudy@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomsStudy@gmail.com Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #3 from Nick Clemens <nick@quecheelibrary.org> --- I tried testing and got odd results with one number displaying as batch id, but the results saving into the DB with a higher batch id, I suspect there is some double increment due to the placeholder records. I am wondering if instead of adding a placeholder at object creation the batch id could be assigned after the first items are added? Maybe assign batch ID -1, don't display it in the add screen, and then in the add items function check for batch id -1 and create the new items then? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #35600|0 |1 is obsolete| | --- Comment #4 from Nick Clemens <nick@quecheelibrary.org> --- Created attachment 35719 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=35719&action=edit Bug 12911 - batch_id for new labels batches can be asssigned to several batches Currently batch_id is assigned upon creation of a new batch object. This patch leaves batch_id as 0 at creation and adds a check when adding items. If batch is new then batch_id is created then Test plan: 1 -In one browser window, go to tools->label creator and click the new batch button 2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button 3 - Note that both batches have the same number listed 4 - Add an item to the first batch - you should now see one item in the batch 5 - Add an item to the second batch, you should see two items in the batch 6 - Apply patch and repeat steps 1&2 7 - Note that neither batch lists a batch number 8 - Add an item to the first batch, you should see one item and a batch number 9 - Add an item to the second batch, you should see one item and a new batch number -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |nick@quecheelibrary.org -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Marjorie Barry-Vila <marjorie.barry-vila@ccsr.qc.ca> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |marjorie.barry-vila@ccsr.qc | |.ca -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 --- Comment #5 from Marc Véron <veron@veron.ch> --- Created attachment 35807 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=35807&action=edit [Signed-off] Bug 12911 - batch_id for new labels batches can be asssigned to several batches Currently batch_id is assigned upon creation of a new batch object. This patch leaves batch_id as 0 at creation and adds a check when adding items. If batch is new then batch_id is created then Test plan: 1 -In one browser window, go to tools->label creator and click the new batch button 2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button 3 - Note that both batches have the same number listed 4 - Add an item to the first batch - you should now see one item in the batch 5 - Add an item to the second batch, you should see two items in the batch 6 - Apply patch and repeat steps 1&2 7 - Note that neither batch lists a batch number 8 - Add an item to the first batch, you should see one item and a batch number 9 - Add an item to the second batch, you should see one item and a new batch number Patch behaves as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |veron@veron.ch Attachment #35719|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #35807|0 |1 is obsolete| | --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 35898 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=35898&action=edit [PASSED QA] Bug 12911 - batch_id for new labels batches can be asssigned to several batches Currently batch_id is assigned upon creation of a new batch object. This patch leaves batch_id as 0 at creation and adds a check when adding items. If batch is new then batch_id is created then Test plan: 1 -In one browser window, go to tools->label creator and click the new batch button 2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button 3 - Note that both batches have the same number listed 4 - Add an item to the first batch - you should now see one item in the batch 5 - Add an item to the second batch, you should see two items in the batch 6 - Apply patch and repeat steps 1&2 7 - Note that neither batch lists a batch number 8 - Add an item to the first batch, you should see one item and a batch number 9 - Add an item to the second batch, you should see one item and a new batch number Patch behaves as expected. Signed-off-by: Marc Veron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master CC| |tomascohen@gmail.com --- Comment #7 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Patch pushed to master. Thanks Nick! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |14204 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chris@bigballofwax.co.nz Status|Pushed to Master |Pushed to Stable --- Comment #8 from Chris Cormack <chris@bigballofwax.co.nz> --- Pushed to 3.18.x will be in 3.18.7 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |14739 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14739 [Bug 14739] Add several patrons to a new batch will create a new batch per patron added -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #9 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> ---
Test plan: 1 -In one browser window, go to tools->label creator and click the new batch button 2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button 3 - Note that both batches have the same number listed 4 - Add an item to the first batch - you should now see one item in the batch 5 - Add an item to the second batch, you should see two items in the batch 6 - Apply patch and repeat steps 1&2 7 - Note that neither batch lists a batch number 8 - Add an item to the first batch, you should see one item and a batch number 9 - Add an item to the second batch, you should see one item and a new batch number
But does not work if you add a second item! See bug 14739 and please provide a quick fix. This bug is much more annoying than the one fixed by this patch. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Nick Clemens <nick@quecheelibrary.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|14739 | See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=14739 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14739 [Bug 14739] Add several patrons to a new batch will create a new batch per patron added -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|Academy | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org