[Bug 15209] New: C4::Koha routines expecting a MARC::Record object should check it is defined
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 Bug ID: 15209 Summary: C4::Koha routines expecting a MARC::Record object should check it is defined Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: MARC Bibliographic data support Assignee: gmcharlt@gmail.com Reporter: colin.campbell@ptfs-europe.com QA Contact: testopia@bugs.koha-community.org This came to light when trying to get plack opac running. A number of routines in C4::Koha return various identifiers from the marc record but do not check it is valid before calling methods on it. The resulting errors cause the plack instance to abort. It is good practice to handle these errors with minimum inconvenience to the user -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 Colin Campbell <colin.campbell@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|gmcharlt@gmail.com |colin.campbell@ptfs-europe. | |com --- Comment #1 from Colin Campbell <colin.campbell@ptfs-europe.com> --- Created attachment 44963 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=44963&action=edit Proposed patch routines now return undef rather than aborting if undefined record is passed to them -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 Jonathan Druart <jonathan.druart@bugs.koha-community.org> 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=15209 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #44963|0 |1 is obsolete| | --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46007 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46007&action=edit Bug 15209 Validate passed MARC::Record objs in C4::Koha Ensure that a passed MARC::Record is defined before calling its methods. Otherwise you are open to occurences of the error 'Can't call method "field" on an undefined value' In a CGI environment you can live with such sloppiness but in a persistent environment the error can cause the instance to abort. Made all routines passed a MARC::Record validate it before calling its methods. Changed the parameter name from the meaningless record to marcrecord to indicate its content. Added an explicit return for all cases where no valid data returned. Cleaned up some logic for clarity. I think we can assume that GetNormalizedOCLCNumber meant to look at all 035s till it found an OCLC number not just the first. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 --- Comment #3 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46008 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46008&action=edit Bug 15209: Add tests Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 --- Comment #4 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46009 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46009&action=edit Bug 15209: Check the parameter at the beginning of the subroutines It seems better to check if parameters exist at the beginning of a subroutine. It makes the code easier to read and there is 1 indentation level less. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal CC| |jonathan.druart@bugs.koha-c | |ommunity.org -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Who signed the| |Jonathan Druart patch off| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15209 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=15209 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46007|0 |1 is obsolete| | Attachment #46008|0 |1 is obsolete| | Attachment #46009|0 |1 is obsolete| | --- Comment #5 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46447 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46447&action=edit Bug 15209 Validate passed MARC::Record objs in C4::Koha Ensure that a passed MARC::Record is defined before calling its methods. Otherwise you are open to occurences of the error 'Can't call method "field" on an undefined value' In a CGI environment you can live with such sloppiness but in a persistent environment the error can cause the instance to abort. Made all routines passed a MARC::Record validate it before calling its methods. Changed the parameter name from the meaningless record to marcrecord to indicate its content. Added an explicit return for all cases where no valid data returned. Cleaned up some logic for clarity. I think we can assume that GetNormalizedOCLCNumber meant to look at all 035s till it found an OCLC number not just the first. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> 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=15209 --- Comment #6 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46448 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46448&action=edit Bug 15209: Add tests Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> 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=15209 --- Comment #7 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46449 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46449&action=edit Bug 15209: Check the parameter at the beginning of the subroutines It seems better to check if parameters exist at the beginning of a subroutine. It makes the code easier to read and there is 1 indentation level less. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org