[Bug 41718] New: draw_guide_grid() passes incorrect arguments to PDF methods, causing warnings.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 Bug ID: 41718 Summary: draw_guide_grid() passes incorrect arguments to PDF methods, causing warnings. Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Label/patron card printing Assignee: chris.nighswonger@veritassuperaitsolutions.com Reporter: chris.nighswonger@veritassuperaitsolutions.com QA Contact: testopia@bugs.koha-community.org Patroncard.pm:219-221: $pdf->Font('Courier'); $pdf->FontSize($font_size); my $strtop_len = $pdf->StrWidth($strtop) * 1.5; There are actually two underlying bugs here: Bug 1 (line 219): Uses hardcoded 'Courier' font name. This may not match a TTF config entry, and the fallback to prFont('Courier') may not work as expected. Bug 2 (line 221): Calls $pdf->StrWidth($strtop) with only one argument, but StrWidth() in PDF.pm expects ($string, $font, $fontSize): # PDF.pm:411 my ( $string, $font, $fontSize ) = @_; $font = C4::Creators::PDF->Font($font); # $font is undef → warnings The correct call should be: my $strtop_len = $pdf->StrWidth($strtop, 'Courier', $font_size) * 1.5; -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 --- Comment #1 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Created attachment 202136 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202136&action=edit Bug 41718: Fix incorrect PDF method arguments in draw_guide_grid() The unit-info rendering at the end of draw_guide_grid() had two argument bugs: 1) $pdf->Font('Courier') passes a font name that matches no entry in koha-conf.xml's <ttf> block (the monospace face is configured under font code "C"), so the TTF lookup warns and falls through to the base-14 fallback instead of the configured font. 2) $pdf->StrWidth($strtop) omits the font and size arguments. C4::Creators::PDF::StrWidth() expects ($string, $font, $fontSize) and passes the undef font into Font(), producing a stream of uninitialized-value warnings and a second failed TTF lookup per call. Use the configured monospace font code "C" for both calls and pass the font and size through to StrWidth(). Verified in koha-testing-docker with the ktd <ttf> configuration: before, one draw_guide_grid() call emits 17 warnings (uninitialized $fontName, missing <font type="Courier"> / <font type="">); after, zero warnings, and the unit-info text renders with the configured DejaVuSansMono TTF instead of the silent base-14 fallback. Test plan: 1) Apply Bug 41719's tests; note t/db_dependent/Patroncards/ t_Patroncard.t filters known Bug 41718 warnings around draw_guide_grid() (see run_allowing_bug_41718_warnings) 2) Apply this patch: prove t/db_dependent/Patroncards/t_Patroncard.t -- all tests pass; the filtered warnings no longer occur 3) Or manually: enable the guide grid in a patron card batch export and check the plack error log -- no font/StrWidth warnings, and the corner unit labels render in the configured monospace font AI Assistance: Claude Fable 5 (Anthropic) implemented the fix from the bug report's analysis, reproduced the warning behavior before and after in koha-testing-docker, and verified the Bug 41719 test suite against the change. Human author reported the underlying defect, directed the approach, and reviewed the change. Assisted-by: Claude Fable 5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 --- Comment #2 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- (In reply to Chris Nighswonger from comment #0) Correction:
my $strtop_len = $pdf->StrWidth($strtop, 'Courier', $font_size) * 1.5;
should read: my $strtop_len = $pdf->StrWidth( $strtop, 'C', $font_size ) * 1.5; -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 --- Comment #3 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- For the QA audit trail: the attached patch was staged and reviewed internally at https://github.com/cnighswonger/koha-wip/pull/93 (review discussion and before/after verification detail). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |41719 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 [Bug 41719] Add rendering test coverage for Labels and Patroncards -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 --- Comment #4 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Setting `depends_on: 41719`. Test coverage for the fixed `draw_guide_grid()` lives on that bug — `t/db_dependent/Patroncards/t_Patroncard.t` exercises the guide-grid render path and the `run_allowing_bug_41718_warnings` filter documents the exact warnings this patch removes. Keeping the two bugs as a pair rather than folding the tests here since 41719 has broader coverage scope (rendering tests for both Labels and Patroncards, not just guide-grid). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 --- Comment #5 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Created attachment 205669 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205669&action=edit Bug 41718: Fix incorrect PDF method arguments in draw_guide_grid() Pre-signoff revision. No code change — the fix is identical to attachment 202136. What changed is the review chain and its disclosure: **Cross-family AI review added.** OpenAI Codex GPT-5.5 (OpenAI) reviewed the patch as an independent second reviewer (different vendor family from the authoring Claude model). Codex verified the "C" font code against `C4/Creators/Lib.pm` and the `etc/koha-conf.xml` / `debian/templates/koha-conf-site.xml.in` `<ttf>` samples; verified the `StrWidth()` call signature against `C4/Creators/PDF.pm`; ran the Bug 41719 test suite independently (all 8 tests pass). No blocker or should-fix findings. The commit message now carries the corresponding `Assisted-by: OpenAI Codex GPT-5.5 (OpenAI)` trailer and an updated descriptive paragraph naming the reviewer's role, per Coding_Guidelines §1.8 §4 (Bugzilla-level AI review disclosure). Setting `depends_on: 41719` per the previous comment stays as-is. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #202136|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org