[Bug 9823] New: Code optimization: Change prototype of GetReservesFromBiblionumber
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Bug ID: 9823 Summary: Code optimization: Change prototype of GetReservesFromBiblionumber Classification: Unclassified Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Circulation Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart@biblibre.com CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com GetReservesFromBiblionumber returns two values while one is enough. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #1 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 16162 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=16162&action=edit Bug 9823: Code optimization: Change prototype of GetReservesFromBiblionumber The prototype of the GetReservesFromBiblionumber routine is quite weird. It is useless to return the number of reserves and an array containing reserves. The $count variable can be calculate with scalar(@$reserves). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Medium patch Assignee|koha-bugs@lists.koha-commun |jonathan.druart@biblibre.co |ity.org |m -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Colin Campbell <colin.campbell@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |colin.campbell@ptfs-europe. | |com --- Comment #2 from Colin Campbell <colin.campbell@ptfs-europe.com> --- Does not apply against master. Jonathan could you rebase? Also could we change patch name to something like Refactor return from GetReservesFromBiblionumber as prototypes are not involved? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #16162|0 |1 is obsolete| | --- Comment #3 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 16236 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=16236&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber as prototypes are not involved The prototype of the GetReservesFromBiblionumber routine is quite weird. It is useless to return the number of reserves and an array containing reserves. The $count variable can be calculate with scalar(@$reserves). -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |8918 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #16236|0 |1 is obsolete| | --- Comment #4 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 16237 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=16237&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber as prototypes are not involved The prototype of the GetReservesFromBiblionumber routine is quite weird. It is useless to return the number of reserves and an array containing reserves. The $count variable can be calculate with scalar(@$reserves). -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Colin Campbell <colin.campbell@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #16237|0 |1 is obsolete| | --- Comment #5 from Colin Campbell <colin.campbell@ptfs-europe.com> --- Created attachment 16256 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=16256&action=edit Amended Patch Patch as amended still did not apply to master, was rejected because it made changes to a subroutine GetReserveNextRank which is not present in master. Have removed the offending line from the patch, modified version attached. I also took the liberty of altering the commit message to clarify what the patch addresses -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #6 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to comment #5)
Created attachment 16256 [details] [review] Amended Patch
Patch as amended still did not apply to master, was rejected because it made changes to a subroutine GetReserveNextRank which is not present in master. Have removed the offending line from the patch, modified version attached. I also took the liberty of altering the commit message to clarify what the patch addresses
Hi Colin, I marked this patch dependent on 8918 because it introduces a call to GetReservesFromBiblionumber. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #7 from Colin Campbell <colin.campbell@ptfs-europe.com> --- Ok I'll re(In reply to comment #6)
(In reply to comment #5)
Created attachment 16256 [details] [review] [review] Amended Patch
Patch as amended still did not apply to master, was rejected because it made changes to a subroutine GetReserveNextRank which is not present in master. Have removed the offending line from the patch, modified version attached. I also took the liberty of altering the commit message to clarify what the patch addresses
Hi Colin, I marked this patch dependent on 8918 because it introduces a call to GetReservesFromBiblionumber.
OK I'll retest when that has been pushed, otherwise it looks ready for signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Magnus Enger <magnus@enger.priv.no> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |BLOCKED CC| |magnus@enger.priv.no --- Comment #8 from Magnus Enger <magnus@enger.priv.no> --- I'm setting this to "BLOCKED" because it is waiting for another patch to be pushed. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|BLOCKED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #16256|0 |1 is obsolete| | --- Comment #9 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 22706 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22706&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber The return from GetReservesFromBiblionumber contains an unnecessary extra variable. In scalar context an array returns its element count. Maintaing a separate count can lead to unforeseen bugs and imposes ugly constructions on the subroutine's users. Remove the useless count variable from the return This patch also changes the parameters: now the routine takes a hashref. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|8918 |9788 --- Comment #10 from Jonathan Druart <jonathan.druart@biblibre.com> --- I remove the dependencies on bug 8918. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|9788 | --- Comment #11 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Removing dependency on pushed 9788. Will look further next week. Still applies. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #12 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Hi Jonathan, Am I wrong if I conclude that you are assigning an arrayref to $count? Quick fix? :) diff --git a/acqui/parcel.pl b/acqui/parcel.pl index ad0e51d..d374fa0 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -174,7 +174,7 @@ for my $order ( @orders ) { $line{holds} = 0; my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} ); for my $itemnumber ( @itemnumbers ) { - my ( $count ) = &GetReservesFromBiblionumber($line{biblionumber}, undef, $itemnumber); + my ( $count ) = &GetReservesFromBiblionumber({ biblionumber => $line{biblionumber}, itemnumber => $itemnumber }); -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Jonathan Druart <jonathan.druart@biblibre.com> 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=9823 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #22706|0 |1 is obsolete| | --- Comment #13 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 24653 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=24653&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber The return from GetReservesFromBiblionumber contains an unnecessary extra variable. In scalar context an array returns its element count. Maintaing a separate count can lead to unforeseen bugs and imposes ugly constructions on the subroutine's users. Remove the useless count variable from the return This patch also changes the parameters: now the routine takes a hashref. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #14 from Jonathan Druart <jonathan.druart@biblibre.com> --- (In reply to M. de Rooy from comment #12)
Hi Jonathan, Am I wrong if I conclude that you are assigning an arrayref to $count? Quick fix? :)
Yes, done! I also changed new occurrences of GetReservesFromBiblionumber in t/db_dependent/Holds.t -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #15 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Jonathan Druart from comment #14)
Yes, done! I also changed new occurrences of GetReservesFromBiblionumber in t/db_dependent/Holds.t
Great. Have been testing some already. Looks good until now. But I cannot finish it today anymore. Will soon pick it up again.. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- 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=9823 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #24653|0 |1 is obsolete| | --- Comment #16 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 24668 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=24668&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber The return from GetReservesFromBiblionumber contains an unnecessary extra variable. In scalar context an array returns its element count. Maintaing a separate count can lead to unforeseen bugs and imposes ugly constructions on the subroutine's users. Remove the useless count variable from the return This patch also changes the parameters: now the routine takes a hashref. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Placed biblio holds, future holds and item holds. Works as expected. Tested Holds.t and Reserves.t. Pass. Tested /cgi-bin/koha/ilsdi.pl?service=GetRecords&id=999 with two holds on one item. Fine. C4/SIP/ILS/Item.pm: Looked for "whatever" and "arrayref" and could not find them anymore. Looks good. Handled a few unneeded calls in QA follow-up. Left only one point to-do for serials/routing-preview.pl. See Bugzilla. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #17 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 24669 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=24669&action=edit Bug 9823: QA follow-up for GetReservesFromBiblionumber calls The template params holds and holdcount are not used in the ISBD template. Removed the associated code from catalogue/ISBDdetail.pl. Same applies for catalogue/MARCdetail.pl and labeledMARCdetail.pl. Same applies also for catalogue/imageviewer.pl. Same applies also for catalogue/moredetail.pl. In catalogue detail.tt only the number of holds is used. Removed the code that passed the holds array to the template. For consistency opac-detail should also incorporate future holds into its holds count; added the all_dates parameter for that reason. The Reserves module is no longer needed in moredetail. Removed it. Checked the other scripts also. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #18 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Comments from testing (some preliminary QA comments for another QAer): Tested /cgi-bin/koha/ilsdi.pl?service=GetRecords&id=999 with two holds on one item. This attracted my attention: - $biblioitem->{'reserves'}->{'reserve'} = $reserves[1]; + $biblioitem->{'reserves'}->{'reserve'} = $reserves; But it is okay: $reserves[1] was previously the arrayref. So this is a code readability improvement too :) With and without patch I see my two holds in the output. Tested Holds.t and Reserves.t. Pass. Placed biblio holds, future holds and item holds. Works as expected (small note below on opac-detail). C4/SIP/ILS/Item.pm: Looked for "whatever" and "arrayref" and could not find them anymore. OK Template params holds and holdcount are not used in the ISBD template; removed them from catalogue/ISBDdetail.pl in QA followup Same for MARCdetail.pl, imageviewer.pl, labeledMARCdetail.pl and moredetail.pl. Removed use Reserves from moredetail (no longer 'in use'.) In catalogue detail.tt only the number of holds is used. Removed the code that passed the holds array to the template. Tested various settings of OPACShowHoldQueueDetails and corresponding display in opac-detail. For consistency I added the all_dates parameter to the call in opac-detail to incorporate future holds in its count. I just note that the display of count and priority could be improved here but I am already at the scope borders of this report :) [The meaning of something like Total holds: 3 (priority 2) under the items list is rather obscure..] serials/routing-preview.pl: I have the strong feeling that this call of GetReservesFromBiblionumber also needs the all_dates parameter. I have not tested this call (there is no test plan for it too :), so I did not want to touch it now. If you could still have a look, Jonathan, perhaps you could still add that one in a follow-up? No complaints from koha-qa.pl. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #19 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Jonathan: the remark on routing-preview.pl actually applies too for: ILSDI/Services.pm C4/Biblio.pm (This one handles deleting reserves, so future ones should be cancelled too) C4/SIP/ILS/Item.pm acqui/parcel.pl Although you could ignore future holds in some counts etc., it makes me wonder if we still need the all_dates parameter and not just include them Always? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #24668|0 |1 is obsolete| | --- Comment #20 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 24690 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=24690&action=edit Bug 9823: Refactor return from GetReservesFromBiblionumber The return from GetReservesFromBiblionumber contains an unnecessary extra variable. In scalar context an array returns its element count. Maintaing a separate count can lead to unforeseen bugs and imposes ugly constructions on the subroutine's users. Remove the useless count variable from the return This patch also changes the parameters: now the routine takes a hashref. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Placed biblio holds, future holds and item holds. Works as expected. Tested Holds.t and Reserves.t. Pass. Tested /cgi-bin/koha/ilsdi.pl?service=GetRecords&id=999 with two holds on one item. Fine. C4/SIP/ILS/Item.pm: Looked for "whatever" and "arrayref" and could not find them anymore. Looks good. Handled a few unneeded calls in QA follow-up. Left only one point to-do for serials/routing-preview.pl. See Bugzilla. 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=9823 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=9823 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #24669|0 |1 is obsolete| | --- Comment #21 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 24691 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=24691&action=edit Bug 9823: QA follow-up for GetReservesFromBiblionumber calls The template params holds and holdcount are not used in the ISBD template. Removed the associated code from catalogue/ISBDdetail.pl. Same applies for catalogue/MARCdetail.pl and labeledMARCdetail.pl. Same applies also for catalogue/imageviewer.pl. Same applies also for catalogue/moredetail.pl. In catalogue detail.tt only the number of holds is used. Removed the code that passed the holds array to the template. For consistency opac-detail should also incorporate future holds into its holds count; added the all_dates parameter for that reason. The Reserves module is no longer needed in moredetail. Removed it. Checked the other scripts also. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> 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=9823 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #22 from Galen Charlton <gmcharlt@gmail.com> --- Pushed to master, along with a follow-up that improves the POD for GetReservesFromBiblionumber. Thanks, Jonathan! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 --- Comment #23 from Galen Charlton <gmcharlt@gmail.com> --- Note bug 11643. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Fridolin SOMERS <fridolyn.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |11829 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9823 Fridolin SOMERS <fridolyn.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |Pushed to Stable CC| |fridolyn.somers@biblibre.co | |m --- Comment #24 from Fridolin SOMERS <fridolyn.somers@biblibre.com> --- Pushed to 3.14.x, will be in 3.14.07 (I've backported this enhancement to be able to backport 11829) -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org