Bug 27746 - Use of uninitialized value $oclc in pattern match (m//) error at C4/Koha.pm
Summary: Use of uninitialized value $oclc in pattern match (m//) error at C4/Koha.pm
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low trivial (vote)
Assignee: Peter Vashchuk
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 25790
  Show dependency treegraph
 
Reported: 2021-02-22 11:43 UTC by Peter Vashchuk
Modified: 2021-04-25 17:25 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.05,20.05.11


Attachments
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc) (1.48 KB, patch)
2021-02-22 11:47 UTC, Peter Vashchuk
Details | Diff | Splinter Review
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc) (1.53 KB, patch)
2021-04-02 19:58 UTC, David Nind
Details | Diff | Splinter Review
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc) (1.61 KB, patch)
2021-04-14 10:15 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 Peter Vashchuk 2021-02-22 11:43:27 UTC

    
Comment 1 Peter Vashchuk 2021-02-22 11:47:26 UTC
Created attachment 117139 [details] [review]
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc)

Some of the books have subfield "a" of field "035" absent
and it's possible to have such
(it doesn't says "Require" in the interface),
which causes "Use of uninitialized value $oclc in pattern match (m//)"
error.

Solved by screening regex with check for empty variables before the
match.

To reproduce:
    1) Edit existing book or create a new one with empty marc
subfield "a" of field "035"
    2) Use the search feature that will find it along with some other
books.
    3) Check /var/log/koha/kohadev/plack-intranet-error.log to find
"Use of uninitialized value $oclc in pattern match (m//)" error.
    4) Apply the patch.
    5) Repeat the search and check the logs again to ensure
that error didn't appear again.
Comment 2 David Nind 2021-04-02 19:58:58 UTC
Created attachment 119144 [details] [review]
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc)

Some of the books have subfield "a" of field "035" absent
and it's possible to have such
(it doesn't says "Require" in the interface),
which causes "Use of uninitialized value $oclc in pattern match (m//)"
error.

Solved by screening regex with check for empty variables before the
match.

To reproduce:
    1) Edit existing book or create a new one with empty marc
subfield "a" of field "035"
    2) Use the search feature that will find it along with some other
books.
    3) Check /var/log/koha/kohadev/plack-intranet-error.log to find
"Use of uninitialized value $oclc in pattern match (m//)" error.
    4) Apply the patch.
    5) Repeat the search and check the logs again to ensure
that error didn't appear again.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Jonathan Druart 2021-04-14 10:15:57 UTC
Created attachment 119555 [details] [review]
Bug 27746: prevent regexp undefined warning when checking subfield contents ($oclc)

Some of the books have subfield "a" of field "035" absent
and it's possible to have such
(it doesn't says "Require" in the interface),
which causes "Use of uninitialized value $oclc in pattern match (m//)"
error.

Solved by screening regex with check for empty variables before the
match.

To reproduce:
    1) Edit existing book or create a new one with empty marc
subfield "a" of field "035"
    2) Use the search feature that will find it along with some other
books.
    3) Check /var/log/koha/kohadev/plack-intranet-error.log to find
"Use of uninitialized value $oclc in pattern match (m//)" error.
    4) Apply the patch.
    5) Repeat the search and check the logs again to ensure
that error didn't appear again.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Jonathan Druart 2021-04-14 13:36:16 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 5 Fridolin Somers 2021-04-19 12:57:45 UTC
Pushed to 20.11.x for 20.11.05
Comment 6 Andrew Fuerste-Henry 2021-04-25 15:18:45 UTC
Pushed to 20.05.x for 20.05.11
Comment 7 Victor Grousset/tuxayo 2021-04-25 17:25:50 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.